Can someone tell me why am I getting "none" as an output?

Question:

the output I’m getting is:
Your grade is X
none
I can’t seem to figure out how to get rid of none.

def computegrade (scr):
    score = float (scr)
    if score >= 0.9 :
        print ("Your grade is A")
    elif score >= 0.8 :
        print ("Your grade is B")
    elif score >= 0.7 :
        print ("Your grade is C")
    elif score >= 0.6 :
        print ("Your grade is D")
    elif score < 0.6 :
        print ("Your grade is F")
    else :
        print ("Enter digits you moron")

scr = input("What was your score?n")
print (computegrade (scr))
Asked By: Aditi Jain

||

Answers:

You need a return statement to actually return a value from a function. Here you just print, so you do not actually return anything.

Just replace your print() with return, eg return "Your grade is F" and you’ll be good.

Answered By: Guillaume
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.