我试图制作一个简单的“猜谜游戏”,但它所做的只是要求输入,仅此而已。
这是我的代码:
import random
def guess():
if a == b:
print "Correct!"
n = input("Press 0 to quit or 1 to try again.")
if n == 0:
print ""
if n == 1:
return guess
else:
print "Wrong! "
n = input("Press 0 to quit or 1 to try again.")
if n == 0:
print ""
if n == 1:
return guess
a = random.randint(1,2000)
b = input("Guess a number between 1 and 2000 ")