Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IF statement Issues
#3
It is indented when I paste it in but when I post it the indentations aren't there.

def main():
    age = eval(input("Enter your age: "))
    citizen = eval(input("Enter the amount of years you have been a citizen: "))
    if age >= 30:
        if citizen >= 9:
            print("You can be a state senator!")
    if age >= 25:
        if citizen >= 7:
                print("You can also be a house representative!")
        
    #I understand that ELSE will only show up if the other IF statements are not triggered
    #but how would one arrange the code to allow ELSE to be triggered if an IF statement is
    #also being used?
    else:
        print("You are not eligible for senate.")
        print("You are also not eligible for the house.")
main()
    

This is a result I got from a specific input:

Enter your age: 25
Enter the amount of years you have been a citizen: 7
You can also be a house representative!
Reply


Messages In This Thread
IF statement Issues - by Kongurinn - Oct-04-2017, 02:02 AM
RE: IF statement Issues - by ichabod801 - Oct-04-2017, 02:08 AM
RE: IF statement Issues - by Kongurinn - Oct-04-2017, 02:13 AM
RE: IF statement Issues - by ichabod801 - Oct-04-2017, 02:16 AM
RE: IF statement Issues - by gruntfutuk - Oct-04-2017, 05:56 AM
RE: IF statement Issues - by ichabod801 - Oct-04-2017, 01:35 PM
RE: IF statement Issues - by Kongurinn - Oct-04-2017, 02:05 PM
RE: IF statement Issues - by nilamo - Oct-04-2017, 03:27 PM

Forum Jump:

User Panel Messages

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