Python-5位无重复数字的随机数生成器 [英] Python - 5 digit random number generator with no repeating digits

查看:898
本文介绍了Python-5位无重复数字的随机数生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该打印一个无重复数字的5位数字,然后要求用户输入3位数字.如果用户号码包含随机数中的三位数,请打印正确".

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 random number, print "correct".

我正在将此代码用于随机数

I am using this code for the random number

num = random.randint (0,99999)
print (num)

问题在于它不会总是打印一个五位数的数字.

The problem is it will not always print a five digit number.

而且,我不知道如何将用户号码与随机数匹配.

Also, I don't know how to match the user number with the random number.

谢谢.

推荐答案

采用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆