0

Could you help me with this.

I created this code to provide a grade (A,B,C...) when a numeric input is given by the user.

try:
    grade = float(inp)
    if grade > 1:
        print ("Out of range")
    elif grade >= 0.9:
        print ("A")
    elif grade >= 0.8:
        print ("B")
    elif grade >= 0.7:
        print ("C")
    elif grade >=0.6:
        print ("D")
    elif grade <= 0.5:
        print("F")
    else:
        print("wrong value")

except:
            print ("Error- Please type a number between 1.0 and 0.0")

if the user types a non numeric answer how can i automatize the repetition of the code?

0 Answers0