Aug-22-2020, 08:38 PM
Use
(Aug-22-2020, 07:21 PM)bitcoin10mil Wrote: Python program that can give me a random 4 digit number without digit repetitionUse random.sample().
>>> import random >>> >>> random.sample(range(10), 4) [6, 8, 9, 7] >>> random.sample(range(10), 4) [7, 6, 2, 3] >>> random.sample(range(10), 10) [0, 4, 9, 2, 6, 8, 1, 7, 3, 5] >>> random.sample(range(10), 10) [8, 4, 6, 9, 5, 0, 1, 2, 7, 3]