E
eltower
Hey all,
I'm trying to write a program in Python for learning purposes which is
meant to:
Generate a random number from 0 to 6
Insert this random number to the end of a list unless the number is
already there
finish with a len(list) = 7
so far, I have this:
import random
random_list = []
while len(random_list) < 8:
j = random.randrange(6)
if (j in random_list):
continue
else:
random_list.append(j)
continue
print random_list
however, I get stuck in an infinite loop.
Any suggestions?
Thank you in advance,
Adri
I'm trying to write a program in Python for learning purposes which is
meant to:
Generate a random number from 0 to 6
Insert this random number to the end of a list unless the number is
already there
finish with a len(list) = 7
so far, I have this:
import random
random_list = []
while len(random_list) < 8:
j = random.randrange(6)
if (j in random_list):
continue
else:
random_list.append(j)
continue
print random_list
however, I get stuck in an infinite loop.
Any suggestions?
Thank you in advance,
Adri