python - Unorderable types in "if" predicate -


def determinelettergrade():     global lettergrade, testavg;     if (testavg <= str(100)) , (testavg >= str(90)):         lettergrade = "a";     else:         if (testavg <= 89.99) , (testavg >= 87):             lettergrade = "b+";         else:             if (testavg <= 86.99) , (testavg >= 80):                 lettergrade = "b";             else:                 if (testavg <= 79.99) , (testavg >= 77):                     lettergrade = "c+";                 else:                     if (testavg <= 76.99) , (testavg >= 70):                         lettergrade = "c";                     else:                         if (testavg <= 69.99) , (testavg >= 67):                             lettergrade = "d+";                         else:                             if (testavg <= 66.99) , (testavg >= 60):                                 lettergrade = "d";                             else:                                 if (testavg <= 59.99) , (testavg >= 0):                                     lettergrade = "f"     # end determinelettergrade function 

midterm project, creating functions, function determinelettergrade. using if statements determine letter grade test average. when go run it, error message:

if (testavg <= str(100)) , (testavg >= str(90)): typeerror: unorderable types: function() <= str() 

the error says on tin: interpreter can't figure out larger when hand function , string. means testavg name of function elsewhere in code. need call it, appropriate arguments, , have return proper value. call once, , save local variable average_score = testavg() (pass arguments needed). can make comparison... shouldn't casting other values strings. leave them integers.

also, should restructure code replace repeated else..if blocks structure uses elif keyword.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -