+ 1
why isn't my code working?
import random nums = [] isAlredyIn = True while len(nums) < 14: num = random.randint(1,14) while isAlredyIn: if num in nums: num = random.randint(1,14) continue else: nums.append(num) isAlredyIn = False print(nums)
2 Answers
+ 6
import random
nums = []
while len(nums) < 14:
while True:
num = random.randint(1,14)
if num in nums:
continue
nums.append(num)
break
print(nums)
Just a little modification.
+ 2
thank you so much!