猜数字炸弹游戏

#coding=utf-8
import random as r
while True:
    newnum=r.randint(1,100)
    lowest=0
    highest=100
    print("范围是%d~%d,猜一猜吧!" % (lowest, highest))
    a=int(input("猜一个数字【不要踩到炸弹!】:"))
    while (a!=newnum and (a<=highest and a>=lowest)):
        print("good!没有猜中炸弹!")
        if a>newnum:
            highest=a
        else:
            lowest=a
        print("现在范围是%d~%d,再猜一猜吧!"%(lowest,highest))
        a = int(input("猜一个数字【不要踩到炸弹!】:"))
    print("真遗憾,你输了!")
    print("本次炸弹:%d"%newnum)

你学废了吗?

你可能感兴趣的:(python)