所以我试着做一个乘法游戏。所以它有点工作,但是当我输入正确的答案时,它会输入“错误”两次......以及如果我输入错误的答案。
import sys #imports sys
random1=['1','2','3','4','5','6','7','8','9','10','11','12'] #makes a list with numbers 1-12
random2=['1','2','3','4','5','6','7','8','9','10','11','12'] #makes another list with numbers 1-12
from random import choice #gets a random number
while True: #makes the following code run in a loop
print "To exit this game type 'exit'" #prints stuff
theyputinstuffhere = raw_input("What is " + choice(random2) + " times " + choice(random1) + "? ") #asks the user things like 1*5 or some other random stuff.
if theyputinstuffhere == "exit": #if the user typed in 'exit' then exit the game
print "Now exiting game!" #prints stuff
sys.exit() #exits
elif theyputinstuffhere == int(choice(random2))*int(choice(random1)): #if what i typed is right, print stuff (I think i messed up here!)
print "Correct!" #print stuff
else:
print "Wrong!" #otherwise print stuff
我不知道我做错了什么帮助!!!!!!!!!!!!!快的!!!!!!!!!!!!!!!!!