Python - 5 digit random number generator with no repeating digits

前端 未结 4 1119
臣服心动
臣服心动 2021-01-06 15:25

I am supposed to print a random 5-digit number with no repeating digits, then ask the user for a three digit number. If the user\'s number contains three digits from the ran

4条回答
  •  轮回少年
    2021-01-06 15:42

    Take a random sample of the digits 0 to 9:

    ''.join(random.sample('0123456789', 5))
    

提交回复
热议问题