【发布时间】:2020-01-05 18:09:29
【问题描述】:
这里是我的 Python 代码
while True:
a = int(input("enter a digit"))
if a < 10:
print("digit is less than 10")
if a < 50 and a > 10:
print("digit is more than 10")
else:
print("error")
所以我的疑问是,当我为 (a 10),输出只是“数字大于 10”,这是正确的,但是当值小于时,为什么会有额外的 else 输出10 .
【问题讨论】:
-
使用
if/elif/else。如果a == 10会发生什么?
标签: python python-3.x if-statement nested