My grade calculator needs the restrictions at the top. If the number entered does not fall into the restrictions the program needs to display the "please try again message". I am new to loops so help would be appreciated
MIN_GPA = 0
MAX_GPA = 4.05
F_grade = 0
D_grade = 0.85
D_plus_grade = 1.15
C_minus_grade = 1.5
C_grade = 1.85
C_plus_grade = 2.15
B_minus_grade = 2.5
B_grade = 2.85
B_plus_grade = 3.15
A_minus_grade = 3.5
A_grade = 3.85
A_plus_grade = 4.05
tgp = float(input("Enter your GPA (0-4):" )) # tgp stands for "Term grade point"
while (tgp<=MAX_GPA) and (tgp >= MIN_GPA):
if (tgp >= F_grade and tgp <D_grade):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is F")
elif (tgp >= D_grade and tgp <D_plus_grade):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is D")
elif (tgp >= D_plus_grade and tgp <C_minus_grade ):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is D+")
elif (tgp >= C_minus_grade and tgp <C_grade ):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is C-")
elif (tgp >= C_grade and tgp <C_plus_grade):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is C")
elif (tgp >= C_plus_grade and tgp <B_minus_grade):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is C+")
elif (tgp >= B_minus_grade and tgp <B_grade):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is B-")
elif (tgp >= B_grade and tgp <B_plus_grade):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is B")
elif (tgp >= B_plus_grade and tgp <A_minus_grade):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is B+")
elif (tgp >= A_minus_grade and tgp <A_grade):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is A-")
elif (tgp >= A_grade and tgp <A_plus_grade):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is A")
elif (tgp == A_plus_grade):
print ("Your GPA is: ", '%.1f'%tgp, "and your letter grade is A+")
else:
print ("\nPlease enter a valid input. Please try again.\n")
continue
break