请告诉我为什么elif被忽略了?我确实在这个话题上得到了几次点击,但是这些并没有多大帮助。
print('Name?')
name=input()
if name=='Alex':
print('ok')
print('Age?')
age=input()
elif age<12:
print('Nice')
outputs:
Name?
Alex
ok
Age?
11
>>>
Name?
Joe
Traceback (most recent call last):
File "/home/User/Documents/python/0006.Practice_o2.py", line 7, in <module>
elif age<12:
NameError: name 'age' is not defined
>>>发布于 2018-08-12 17:41:48
尝尝这个。您应该在父服务器中包含if age<12,如果
print('Name?')
name=input()
if name=='Alex':
print('ok')
print('Age?')
age=input()
if age<12:
print('Nice')https://stackoverflow.com/questions/51811261
复制相似问题