Python Forum
help! if statement not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help! if statement not working
#1
so i need to write a code that will do the following
#ask for name
#ask for health score
#ask for grade
#ask for economic output
#if the grade is A OR economic output is above 85 print they meet the criteria
#if the health score and economic output are both over 60 and grade is at least a C print congratulations
#otherwise print sorry

I have written the below but it doesnt work. It doesnt print the correct statements at the end.
can someone show me where i am going wrong please.



name = raw_input("Enter your name:")

health = raw_input("Enter your standardised health score:")

grade = raw_input("Enter your standardised grade:")

economic = raw_input("Enter your standardised economic output score:")

if grade == "A" or economic >85:
print name, "you meet the exceptional criteria."
elif health and economic >60 and grade >= "C":
print "Congratualtions", name, "you have been selected."
else:
print "Sorry", name, "you are not permitted to board the ship."
Reply
#2
Please put your code in Python code tags, you can find help here.

Can you provide an example case(s) of what was your input, and actual vs. desired output?
Reply
#3
Some testing is in order when it doesn't work. This is enough to reveal the first mistake in your code. And I would suggest that you go through a tutorial as it wastes everyone's time to ask a question that is answered in most every tutorial https://wiki.python.org/moin/BeginnersGuide/Programmers
name = raw_input("Enter your name:")

health = raw_input("Enter your standardised health score:")

grade = raw_input("Enter your standardised grade:")

economic = raw_input("Enter your standardised economic output score:")

if grade == "A":
    print "grade ==A OK":
if economic >85:
    print "economic > 85"  
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  if statement not working g0g0g1g 2 1,607 Sep-08-2020, 05:40 PM
Last Post: nilamo
  Else Statement Not Working SenkouSimmer 4 3,175 Jul-22-2019, 11:42 AM
Last Post: jefsummers
  Simple IF statement not working as intended gortexxx 2 2,744 May-17-2018, 07:54 PM
Last Post: gortexxx

Forum Jump:

User Panel Messages

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