我正在尝试制作一个四位数的长列表,没有重复的数字。但是,我正在运行的代码仅生成一位数字,然后关闭。有人能明白为什么吗?import randomcomplist = [0,1,2,3,4,5,6,7,8,9]compnum = []userlist = []usernum = []def compnumber(compnum): for i in range(4): compx = random.randint(0,9) if compx in compnum: compx = 0 return compx, compnum else: compnum.append(compx) compx = 0 return compx, compnumcompnumber(compnum)print(compnum)谢谢!
添加回答
举报
0/150
提交
取消