我正在学习python并练习一些控制流程语句, 我的计划是:
name = 'ravi'
print ('enter your username first')
Username =input()
if name ==Username:
print ('hi '+Username)
print ('enter your age')
age = input()
if age < 18:
print ('you are not valid Kido')
elif age > 2000:
print('Unlike you, Alice is not an undead, immortal vampire.')
elif age > 100:
print('You are not Alice, grannie.')
elif age>=18:
print ('Welcome in our portal')
每次运行此代码时都会出错:
enter your username first
ravi
hi ravi
enter your age
18
错误是:
Traceback (most recent call last):
File "C:\Users\Ravi\AppData\Local\Programs\Python\Python36\NEWpASSWORD.py", line 11, in <module>
if age < 18:
TypeError: '<' not supported between instances of 'str' and 'int'