-2
Make a program that creates two vectors with 10 random elements between 1 and 100. Generate a third vector of 20 elements, whose values should be composed of the interspersed elements of the two other vectors. Print the three vectors.
I wonder if the code I made is correct and if possible show me another way to do it thank you.
import random
lista1 = []
lista2 = []
lista3 = []
while len(lista1) < 10:
numero = random.randint(1,100)
if numero not in lista1:
lista1.append(numero)
lista3.append(numero)
while len(lista2) < 10:
numero = random.randint(1,100)
if numero not in lista2:
lista2.append(numero)
lista3.append(numero)
lista1.sort()
lista2.sort()
lista3.sort()
print(lista1)
print(lista2)
print(lista3)
Your show is doing something you didn’t expect?
– hugomg
I don’t really know if it’s the best way to do it.
– Ed S