Skip to content
Advertisement

When entering the wrong input, Gives ‘str’ is not callable error

The error occurs in the def ‘newround()’, and the given options are Yes/No, however when entering something like ‘test’ it says the else statement but then gives an error anyways. I looked up some info on the error, and the best thing i could find was if a variable was called ‘str’ but none of my variables are even close to that so I’m not sure why I get this error, also I’m new to coding so apologies if it’s something simple. Here is the code:

JavaScript

Here is the error message:

JavaScript

Advertisement

Answer

In def newround, you have a variable called playagain, but inside the except part, you use it as a function. Maybe, rename your variables such that there would be no interference variables and function names.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement