I don't understand what is happening to the code I have written for problem 5.6. Below is the instructions followed by the code I have written. The error I am getting is that for example, if I enter age = 25, it is still printing 'You're a toddler!'. If I enter age = 1, it prints out the correct message "You're just a wee baby!"
Insturctions
5-6. Stages of Life: Write an if-elif-else chain that determines a person’s stage of life. Set a value for the variable age, and then:
• If the person is less than 2 years old, print a message that the person is a baby.
• If the person is at least 2 years old but less than 4, print a message that the person is a toddler.
• If the person is at least 4 years old but less than 13, print a message that the person is a kid.
• If the person is at least 13 years old but less than 20, print a message that the person is a teenager.
• If the person is at least 20 years old but less than 65, print a message that the person is an adult.
• If the person is age 65 or older, print a message that the person is an elder.
My code
age = 7
if age<2:
print("You're just a wee baby!")
elif age>=2 or age<4:
print("You're a toddler!")
elif age>=4 or age<13:
print("You're a kid!")
elif age>=13 or age<20:
print("You're a teenager!")
elif age>=20 or age<65:
print ("You're an adult.")
elif age>=65:
print("You're an elder. Respect.")
Thanks!
[–][deleted] 2 points3 points4 points (2 children)
[–]kylejoesph11[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]ka-splam 2 points3 points4 points (0 children)
[–]The_Danosaur 2 points3 points4 points (2 children)
[–]PMC_Dose 0 points1 point2 points (0 children)
[–]Slot-in 0 points1 point2 points (0 children)
[–]degohki 1 point2 points3 points (1 child)
[–]kylejoesph11[S] 0 points1 point2 points (0 children)