猜数字小游戏(python)

import random

while 1:
    answer = random.randint(1,100)
    for i in range(6):
        print("你还有"+str(6-i)+"次机会")
        guess = int(input("请输入你的答案"))
        if answer==guess:
            print("恭喜你,猜中了")
            print("你的成绩是"+str(100-i*10))
            break
        elif answer>guess:
            print("你的答案太小了")
        elif answer             print("你的答案太大了")
    else:
        print("猜错了,继续努力")
    flag=input("是否继续?(回车继续,输入任意字符退出)")
    if flag !="":
        break
print("游戏结束")
   

你可能感兴趣的:(python)