Python Forum

Full Version: Any input passes and an "A"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
apparently any str passes as an "A" in my code. how do i fix this

gradeletter = str(input("Enter your Letter Grade: "))
def GPAcalc(grade):
    if (gradeletter == "A" or "a" or "B" or "b" or "C" or "c" or "D" or "d" or "F" or "f"):
        if (gradeletter == "A" or "a"):
            return (4)
        if (grade == "B" or "b"):
            return (3)
        if (gradeletter == "C" or "c"):
            return (2)
        if (gradeletter == "D" or "d"):
            return (1)
        if (gradeletter == "F" or "f"):
            return (0)
    else: print ("Invalid")

print(GPAcalc(gradeletter))
didnt help me. My program has no error it just doesnt output correctly.
also are you insulting me with that quote?
(Mar-10-2019, 06:29 PM)JTNA Wrote: [ -> ]didnt help me. My program has no error it just doesnt output correctly.
also are you insulting me with that quote?

Click on the link that buran kindly posted for you,
Read what it says in the linked thread to explain why multiple expressions with "or" keyword give unexpected results,
Thank buran for the link.