python3 - while循环控制语句
2017-02-06 14:20 菜鸟Alex 阅读(877) 评论(0) 编辑 收藏 举报
number = 7
guess = 0
print("猜字游戏现在开始")
while guess != number:
# 将输入的类型转为int,否则默认是字符串不能做比较大小
guess = int(input("请输入你猜的数字\n"))
if guess == number:
print("恭喜你答对了")
elif guess > number:
print("大了")
elif guess < number:
print("小了")