import numpy as np
num = np.random.randint(9)
input_num = int(input("Please input a word to guess the right number: "))
while 1:
if num== input_num:
print("You are right! Want to have another try(y/n): ")
answer = input()
if answer in ["y", "Y"]:
num = np.random.randint(9)
input_num = int(input("Please input a word to guess the right number: "))
else:
print("Game over ! ")
break
else:
print("The answer you input is not the right one, please try again(q to quit): ")
an = input()
if an in ["q", "Q"]:
break
else:
input_num = int(an)
利用while循环写一个简单的数字游戏
最新推荐文章于 2022-05-16 15:05:09 发布