这是我的代码:
def main():
mycolours = ['R', 'G', 'B', 'Y', 'P', 'O']
myguess = 'RGBY'
total_guess = 5
x = random.shuffle(mycolours[:4])
for i in range(total_guess):
if myguess == x:
print('CORRECT')
else:
print('TRY AGAIN')
main()
它不是从列表中返回4个随机字符串,而是返回值none
Tags:
您可以通过导入random来洗牌元素,所以让
那么你可以说
它会打印出来
如果你想要很多随机的数字,那么
现在z将是这样的
希望这有帮助
相关问题 更多 >
编程相关推荐