+ 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)

13th Dec 2019, 1:38 PM
Alon
Alon - avatar
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.
13th Dec 2019, 1:49 PM
Ipang
+ 2
thank you so much!
14th Dec 2019, 12:31 PM
Alon
Alon - avatar