为啥这个代码运行后输出的是adult
age=('17')
if age<18:
print('teenager')
else:
print('adult')
age=('17')
if age<18:
print('teenager')
else:
print('adult')
2023-06-13
Computer regarded your
『('17')』 of 『age=('17')』 as a 'string',not a 'number'.
So it's working like down here
else:
print('adult')
If you change your code from
____________________________________
age=('17') <-----------------------
if age<18:
print('teenager')
else:
print('adult')
____________________________________
to
____________________________________
age=17
<------------------------
if age<18:
print('teenager')
else:
print('adult')
____________________________________
That will be correct.
Enjoy your coding.(^_^)
举报