19. Review functions: type == int or type == float


#1

Continuing the discussion from 19. Review: Built-In Functions:

I'm curious as to why you can't type


type(a) == int or float

instead of

type(a) == int or type(a) == float

anyone care to enlighten me?


#2

well, python will evaluate both sides of the or operator:

type(a) == int
float

given float isn't compared to anything, python will simply analyze if float is considered true or false


#3

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