print("Welcome to the Age Classifier program")
person_age=(float(input("Enter the person's Age"))
if person_age<=1 or person_age>0:
print("Person is an infant")
elif person_age>1 or person_age<13:
print("Person is a child")
elif person_age>=13 or person_age<20:
print("Person is a teenager")
elif person_age>=20 :
print("Person is an adult")
else:
print("Person has not been conceived or is developing in the womb")
當我執行這段代碼,解釋報告說,沒有對if
陳述的身體一號線錯誤,有消息報道說語法是無效的。我嘗試添加括號並遇到相同的語法錯誤。年齡分類的Python程序
在這種情況下,即使輸入爲'-1',輸出也會是''人是嬰兒''。 –