我正试图在Python 3中制作一个简单的唤醒文件,但我似乎无法让我的列表和输入相互配合。
这是代码:
from random import *
difficulty = (int(input("How many random numbers: ")))
list = []
for i in range(difficulty):
numbers = randint(0, 10)
list.append(numbers)
print(list)
answer = (input("Write the same numbers in the right order: "))
split = answer.split()
print(split)
if split == list:
print("Correct!")
else:
print("Wrong!")
如果要将strigns列表与int列表进行比较,请使用:
split = [int(a) for a in answer.split()]