+ 1
Why it doesn't print elements with numbers?
6 Answers
+ 3
You write:
number==int
Instead use:
type(number) is int
or:
isinstance(number, int)
number is, well a number and int is the type int. It's a different thing, not equal.
Instead you want to know if the type of number is int.
+ 2
Because of: number == int
int is a class and no integer is equal to the class.
+ 1
Seb TheS 5.0 == int results in True. I don't understand.
+ 1
liste = ["345","sadas","324a","14","kemal"]
for i in liste:
for x in i:
try:
number = int(x)
print(number)
except:
continue
+ 1
Baran Aldemir int is a class.
5 == int ---> False
5.0 == int ---> False
5.0 == 5 ---> True
+ 1
Seb TheS Oh sorry. You're right it returns false.I misremembered it.