0
import random
x = int(input("Digite o tamando do cromossoma: "))
n = int(input("Digite a quantidade de vetores: "))
saida = []
for _ in range(x):
saida.append(random.randint(0, 1))
print(saida)
0
import random
x = int(input("Digite o tamando do cromossoma: "))
n = int(input("Digite a quantidade de vetores: "))
saida = []
for _ in range(x):
saida.append(random.randint(0, 1))
print(saida)
1
One solution to this type of situation is to use comprehensilist on:
import random
x = int(input("Digite o tamando do cromossoma: "))
n = int(input("Digite a quantidade de vetores: "))
saida = []
for _ in range(x):
saida.append([random.randint(0,1) for i in range(n)])
for vector in saida:
print(vector)
Returns n
dimension vectors x
each one.
Browser other questions tagged python
You are not signed in. Login or sign up in order to post.
If one of the answers below solved your problem and there was no doubt left, choose the one you liked the most and mark it as correct/accepted by clicking on the " " that is next to it, which also marks your question as solved. If you still have any questions or would like further clarification, feel free to comment.
– Lucas