Here is my code plus the error message I'm getting:
What could I be doing wrong?
abs() is a function that returns the absolute value of whatever is placed inside the parentheses. In this case we want the absolute value of m, so we would write
That solved it! Thanks!
Your function is printing "nope" when it should be returning "nope".
Have you tried putting nope in quotes i.e. "Nope" ?
The extra None that is printed in the console is a result of how Codecademy processes your code. If you were to run the same code in another interpreter you would not see that None. If you would like to test this you can use the
Exactly ! That's what my question is.. I don't get it in other
interpreters. How am I supposed to complete this exercise now? And
continue with the course. Please give some suggestion.
The problem is with your if statement. Currently you have:
if type(d) == int or float:
And I understand why it would be tempting to write it that way, but with programming we need to be very specific so it actually needs to be written as:
if type(d) == int or type(d) == float
Also, as @muzakir said, make sure you have:
else: return 'nope'
Thank you so much mkordik. It's solved but I still don't understand why it didn't throw a syntax error or something
The syntax wasn't wrong in terms of Python being able to process it. It was wrong because it wasn't checking what you really wanted to check.
Here is a good post on why it did what it did:
if type(n) == int or type(n) == float:
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.