What’s wrong with my code?
I assume this is an obvious and basic solution but I’m just beginning to learn, I’ve got no idea and can’t find an answer in my previous lessons.
The problem is on line 12 (below. score and max are both previous input values, the main py isn’t detecting any grammar issues but the console can’t get past it.
Thanks in advance!
If you read the error message it says there is a string and it expected an int. This is because score is still a string.
This means line 12 is trying to do int(string/int) that is not possible.
@Renegon! Welcome to the community!
Since this is a help on a course, we won’t exactly give the direct answer, but we can guide you along the right path.
When your program is running that line of code, it’s running it like this:
final_percentage = int('42' / 69) # ==> final_percentage = int(score / max)
Since Python is a strongly-typed language, it will produce a
Try finding a way to turn
score into an integer.
I wouldn’t say strongly typed, it is actually known for its loose typing. In “strongly typed” languages, getting into a situation like this is almost impossible with a decent knowledge of types.
Well JS is a mess and what you describe causes bad habits. But hey I dislike JS and by now this is known.
Python is dynamically typed but at least it does give errors like this as such a thing should never be allowed.
But I will say that the errors are useful, because it makes programmers more consistent with their types, and like what you said, avoid bad habits.