In [8]:
def win():
print("You win!")
def lose():
print("You lose.")
def menu():
print('''=====game menu=====
1.show instructions
2.start the game
3.exit
=====game menu=====''')
def instructions():
print("please guess an integer.")
menu()
choice = int(input("please enter an integer: "))
if choice == 1:
instructions()
print("start: ")
k = int(input("please enter the limited times: "))
i = 0
result = 0
while i <= k:
m = random.randint(1,1000)
print(m)
result = int(input("please enter the number: "))
if result == 1:
win()
break
else :
lose()
i += 1
if i == k:
print("You've run out the times,sorry.")