-3

What I am learning is very basic. I have written a short program from a book I am learning from and I wanted to modify it slightly so that you can loop again and use an end function instead of simple answering once and the program ends. This is what I have:

WhatsMyGrady.py

grade=eval(input("Enter the number of your grade (0-100):"))
while grade !="end":
if grade>=90:
    print("You got an A!:)")
elif grade>=90:
    print("You got a B!")
elif grade>=80:
    print("You got a C.")
elif grade>=70:
    print("You got a D...")
elif grade>=60:
    print("you got an F.")
elif grade<59:
    print("You Fail!")
grade=input("select another grade or enter 'end' to quit")

Traceback (most recent call last): File "C:\TheseusP&GS\Python\teaching_your_kids_code\what_my_grade.py", line 4, in if grade>=90: TypeError: '>=' not supported between instances of 'str' and 'int'

this is the error im recieveing.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

You're comparing a string and an int with >=. Instead, do this.

grade=input("Enter the number of your grade (0-100):")
while grade !="end":
    grade = int(grade)
    if grade>=90:
        print("You got an A!:)")
    elif grade>=90:
        print("You got a B!")
    elif grade>=80:
        print("You got a C.")
    elif grade>=70:
        print("You got a D...")
    elif grade>=60:
        print("you got an F.")
    elif grade<59:
        print("You Fail!")
    grade=input("select another grade or enter 'end' to quit")
rma
  • 1,853
  • 1
  • 22
  • 42