Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If Statement
#3
#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
Reply


Messages In This Thread
If Statement - by Bobcat - May-02-2020, 03:28 PM
RE: If Statement - by buran - May-02-2020, 03:36 PM
RE: If Statement - by pyzyx3qwerty - May-02-2020, 03:55 PM
RE: If Statement - by buran - May-02-2020, 04:01 PM
RE: If Statement - by buran - May-02-2020, 04:03 PM
RE: If Statement - by menator01 - May-02-2020, 07:24 PM
RE: If Statement - by buran - May-02-2020, 07:27 PM
RE: If Statement - by menator01 - May-02-2020, 07:47 PM
RE: If Statement - by buran - May-02-2020, 07:57 PM
RE: If Statement - by pyzyx3qwerty - May-03-2020, 04:57 AM
RE: If Statement - by menator01 - May-02-2020, 08:00 PM
RE: If Statement - by buran - May-02-2020, 08:14 PM
RE: If Statement - by ndc85430 - May-03-2020, 05:00 AM

Forum Jump:

User Panel Messages

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