基本上我为随机测试答案getter做了一些代码。我的想法是,它会给你一个随机答案,从一个选项。当我运行这个代码时,它似乎会被拒之门外。为什么我的随机答案getter的代码不工作?
下面是代码:
import random
Question_total = int(input("How Many answers do you need?"))
x = random.choice('abcd')
print(x * Question_total)
当我输入一个号码,它只是退出了。这里是错误(我输入四个):
dddd
Exit status: 0
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
帮助将不胜感激。
您需要一个循环。您正在生成一个随机结果,然后重复该结果字符串几次。 –