0
gradeOutput= ['A','B','C','D','E','F']
#USE OF IF STATEMENT TO SORT USER DATA
if ((grade== gradeOutput[0]) or (eco >= 85)):
 print("Great!, you have met the highest criteria")
elif ((grade== gradeOutput[0:3]) and (health >= 60) and (eco >= 60)):
 print("Congratulations you have met the criteria")
else :
 print("Apologises, you have not met the criteria")

I am current doing a basic task for my coursework and I'm stuck and I'm not sure why.

I have created my list and using the 0,1,2,3,4 rule. I have asked in the elif for the grade to be between A-C, economic status to be a minimum of 60, and the health score to be minimum of 60 to access onwards but when I insert the correct details such as, Grade C, 70 Economic status and 70 health it gives me the else statement which stops the program.

Any help would be grateful.

Charles
1,12019 silver badges30 bronze badges
asked Aug 16, 2017 at 1:47

2 Answers 2

1

In your elif statement you are comparing a single item (grade) to a list of items (['B', 'C', 'D']). You need to change to:

elif grade in gradeOutput2[0:2] and health >= 60 and eco >= 60: 
 print("Congratulations you have met the criteria")
answered Aug 16, 2017 at 1:56
Sign up to request clarification or add additional context in comments.

Comments

0
grade == gradeOutput2[0:2]

I believe you intend to check if grade is within that slice. Therefore, use the syntactic sugar of in to check if your element is within that slice, NOT if it is equivalent.

grade in gradeOutput2[0:2]
answered Aug 16, 2017 at 1:56

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.