0

Something is wrong with my code... [Answered thank you.]

I'm trying to make a base that does >=17 no <=18 yes <=100 wow Link https://code.sololearn.com/c3937hR7rxvq/?ref=app

26th Jan 2023, 3:49 PM
RocketLover
9 Respuestas
+ 5
Mark, The else is the base case, elif needs to go above: Also 101 would stop on the first case as you are over 18. This would work: age = int(input()) if age >= 100: print("old") elif age >= 18: print("allowed") else: print("Sorry, You need to leave.")
26th Jan 2023, 4:07 PM
DavX
DavX - avatar
+ 1
Alright, That one worked. Thank you!
26th Jan 2023, 4:05 PM
RocketLover
+ 1
Mohammad, this was already answered - the elif condition will never fire (needs >= 100 and also to be moved to the top)
27th Jan 2023, 7:43 AM
DavX
DavX - avatar
0
Can you send a copy of it please?
26th Jan 2023, 3:58 PM
RocketLover
0
It still says Allowed in though...
26th Jan 2023, 4:02 PM
RocketLover
0
Oh I see, it needs to be above 100 not below it. My bad, I forgot to elaborate more.
26th Jan 2023, 4:03 PM
RocketLover
0
Also works, Thank you.
26th Jan 2023, 4:10 PM
RocketLover
0
age = int(input()) if age >= 18: print("Allowed in! Cmon! Lets go have fun!") elif age <=100: print("w h a t t h e") else: print("Sorry, You need to leave.")
27th Jan 2023, 5:28 AM
MOHAMMAD IMRAN
MOHAMMAD IMRAN - avatar
0
Elif comes before else
27th Jan 2023, 4:44 PM
Sairaj Bhise
Sairaj Bhise - avatar