currently I am getting to grips with Python and I am trying to produce a small script, however I am having issues with an IF statement, ideally I would like it so if the user inputs an "N" or 'n' for "No" then I like this sentence to be displayed "Thank you for using FinalGrade. Goodbye." However, it only loops back and reacts as if I had entered "Y", allowing another student to be inputted.
Heres my code:
results = []
cont = 'y' or 'Y'
print ("\n")
print ("-----------------------------------------------------------------------------")
print ("\n")
Institution = str(input("Please Enter the Name of Your Insitution: "))
while cont=='y' or 'Y':
print ("\n")
print ("---------------------------------NEW STUDENT---------------------------------")
print ("\n")
Year = str(input("Please Enter the Year of the Student (For Example, 'Year 1 / 2 / 3 / 4'): "))
print ("\n")
print ("-----------------------------------------------------------------------------")
print ("\n")
Student = str(input("Student Full Name: "))
print ("\n")
Grade1 = int(input("Enter Student's First Term Grade: "))
Grade2 = int(input("Enter Student's Second Term Grade: "))
Grade3 = int(input("Enter Student's Third Term Grade: "))
Grade4 = int(input("Enter Student's Fourth Term Grade: "))
average = (Grade1+Grade2+Grade3+Grade4)/4
print ("\n")
print ("-----------------------------------------------------------------------------")
print ("\n")
print ("Total Grade Average: %G" % (average))
passed_or_failed = "PASSED"
if average < 40:
passed_or_failed = 'FAILED'
results.append(passed_or_failed)
print ("\n")
print ("%s has: %s" % (Student, passed_or_failed))
print ("\n")
The main issues I am having in my code are shown below:
cont = input('Do you want to keep entering students? Y/N: ')
if cont=='N' or 'n':
print ("\n")
print ("-----------------------------------------------------------------------------")
print ("\n")
print ("Thank you for using FinalGrade. Goodbye.")
Is there any solution to this problem? Thank you.