Oct-04-2017, 02:02 AM
#hey everyone I am a new student in Python. Below is some code working on IF statements. Please
#refer to the comment question in the middle of the page.
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()
#Please see previous comments
#refer to the comment question in the middle of the page.
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()
#Please see previous comments