python 简单版猜数字

Kinghero King of the summit 2021-08-05 19:22:34 2021-10-10 14:01:06 3
    import random
    ans = random.randint(1, 100)
    b = 0
    while True:
        a = int(input('请输入一个1~100的整数。'))
        if (a > ans):
            print('猜大了。')
            b += 1
        if (a < ans):
            print('猜小了。')
            b += 1
        if (a == ans):
            print('恭喜你!中了100亿。')
            break
        if (b == 8):
            print('猜数结束,正确答案是,', ans, ',你错过了100亿!', sep = '')
            break
{{ vote && vote.total.up }}