May-02-2020, 03:55 PM
(This post was last modified: May-02-2020, 04:07 PM by pyzyx3qwerty.)
#Ask user for details name = (input("Enter your name: ")) age = int(input("Enter your age: ")) country = (input("Enter country of citizenship: ")) #Check if eligible to vote if age <18: print (age, "You are not yet old enough to vote: ") #If over 18 and from Britain or UK you are entitled to vote elif age >18 and country == "Britain" or country == "UK": print ("You are entitled to vote: ") #Otherwise elif country != "Britain" or country !="UK": print ("Sorry you are not entitled to vote: ")Fixed it
use
country == "Britain" or country == "UK"
instead of elif age >18 and country == "Britain" or "UK":
output :
Output:Enter your name: Jack
Enter your age: 20
Enter country of citizenship: USA
Sorry you are not entitled to vote:
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs