Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I don't get this....
#1
Hello, everybody....I am new to this forum...And definitely very new in programming, ANYTHING....I have these few lines of code on the if, elif...just seven lines, I think...no matter what I do it evaluates to 'false' or 'sorry, you're not qualified to vote'. I've tried modifying the variables, to just one key, two values (age = 20,21) it still evaluates to false...somebody said there has to be a variable when getting input...I tried that...still no way...then somebody said that this is a python quirk, where python will only evaluate zero (0) as false, and everything else is evaluated to true...that just sounds a little off to me, and I don't wanna buy that .... yet.
I hope somebody from y'all can slap my head with a washing paddle and show me what I'm doing wrong....
Thanks a lot...
Here's the source code:

your_age= 20
your_age=21


input('please indicate your_age. ')

if 20:
    print('sorry. you are not yet qualified to vote.')
elif 21: 
    print ('good. please proceed to the voting booth.')
Whichever age I input, the answer comes back "sorry, you're not yet qualified to vote".
And if it's any help, I use both the 2.7 and 3.6 versions.

Thanks again.

Pancit Bihon

PS : I've also tried this way, still no way...

your_age= 20
your_age=21


input('please indicate your_age. ')

if your_age <= 20:
print('sorry. you are not yet qualified to vote.')
elif your_age >=21:
print ('good. please proceed to the voting booth.')

This gives the 'good. please proceed...' response whichever age is indicated.
Reply


Messages In This Thread
I don't get this.... - by pancit_canton - Jan-26-2018, 12:12 PM
RE: I don't get this.... - by j.crater - Jan-26-2018, 12:20 PM
RE: I don't get this.... - by pancit_canton - Jan-26-2018, 12:57 PM
RE: I don't get this.... - by wavic - Jan-26-2018, 06:11 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020