python3 - while循环控制语句
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(
"小了")