Review: Built-In Functions


#1

Hello

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'

Screen:


#2

yes, you have to.

using:

if type(n) == int or float:

python will simply check if float will evaluate to true:

if float:
    print True
else: 
    print False

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


#3

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