Review: Built-In Functions



I wonder why my code is not working correctly. Is it impossible to use "if type(n) == int or float:" ? Do i have to use if type(n) == int or if type(n) == float?

Error: Your function seems to fail on input True when it returned '1' instead of 'Nope'



yes, you have to.


if type(n) == int or float:

python will simply check if float will evaluate to true:

if float:
    print True
    print False

float is considered true, so then the condition would always be true


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.