課程
/后端開發(fā)
/Python
/Python3 入門教程(新版)
age=('17')
if age<18:
? print('teenager')
else:
? ? ? print('adult')
2023-06-13
源自:Python3 入門教程(新版) 4-2
正在回答
你的17定義的是字符串......把引號去了就行
age=('17')你這樣給是字符串,正常會產(chǎn)生錯誤,如下not supported between instances of 'str' and 'int',
改成age =17即可
Computer regarded your
『('17')』 of? ?『age=('17')』 as a 'string',not a 'number'.
So it's working like down here
If you change your code from
____________________________________
age=('17')? ? ? <-----------------------
to
age=17? ? ? ?
? <------------------------
? ? print('teenager')
? ? print('adult')
That will? be correct.
Enjoy your coding.(^_^)
舉報
python3入門教程,讓你快速入門并能編寫簡單的Python程序
1 回答為啥有'...'后再出現(xiàn)adult
1 回答為啥運行出來a是個空集
1 回答這個代碼為啥也跑不出來
1 回答為什么這個代碼不能輸出?
1 回答為什么這個運行后沒有結(jié)果,代碼沒有錯誤
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2024-01-17
你的17定義的是字符串......把引號去了就行
2023-09-10
age=('17')你這樣給是字符串,正常會產(chǎn)生錯誤,如下not supported between instances of 'str' and 'int',
改成age =17即可
2023-06-14
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.(^_^)