lundi 28 septembre 2020

Confused by use of If-else

I'm running this piece of code in a compiler:

def main():
  print("This program will produce a letter grade equal to the numerical exam score given")

  int(input("Input numerical grade score:"))

  grade=["A","B","C","D","F"]
  
  if grade>=90:
    return 'A'
  if grade>=80:
    return 'B'
  if grade>=70:
    return 'C'
  if grade>=60:
    return 'D'
  else:
    return 'F'
 
  print("The letter grade for this score is:",grade)

main()

Whenever I try and put a numerical score in, I get this error:

This program will produce a letter grade equal to the numerical exam score given
Input numerical grade score:55
Traceback (most recent call last):
  File "main.py", line 21, in <module>
    main()
  File "main.py", line 8, in main
    if grade>=90:
TypeError: '>=' not supported between instances of 'list' and 'int'

I have no idea what it's trying to say to me or how to fix it

Aucun commentaire:

Enregistrer un commentaire