Python 猜数字游戏

#猜数游戏

#2019.2.22  9:28

import random

secret=random.randint(1,99)#电脑随机产生的数

guess=0                    #你猜的数

tries=0                    #猜的次数

print("Hi,I am Snake,and I have a secret")

print("It is a number[1,99],I will give you 6 tries")

while guess!=secret and tries<6:

    guess=int(input("What's you guess?"))#int是将字符串转化为整形

    if guess>secret:

        print(str(guess)+"is too hight,Baby!")

    elif guess

        print(str(guess)+"is too low,come on!")

    tries=tries+1

if guess==secret:

    print("Awsome!you got it!Found my secret!")

else:

    print("no more chance!foolish!Better luck next time")

    print("I can tell you the secret number was ",secret)

你可能感兴趣的:(Python 猜数字游戏)