0

Why?

print( bool('0==1') ) This gives True, which is counterintuitive to me. 0 == 1 is not True therefore it is False, isn't it?

17th Oct 2016, 12:51 AM
Eunjae Lee
Eunjae Lee - avatar
5 odpowiedzi
+ 6
strings are always True it means that , bool("wi")==True bool("2")==True bool("True")==True bool("False")==True bool("1==2")==True only empty strings returns False bool("")==False hope I helped
17th Oct 2016, 6:54 AM
Sunera
Sunera - avatar
+ 3
The string "0==1" is not 0, so it is evaluated to True. Try print( bool(0==1)) instead.
17th Oct 2016, 1:16 AM
Zen
Zen - avatar
0
strings are always True it means that , bool("wi")==True bool("2")==True bool("True")==True bool("False")==True bool("1==2")==True only empty strings returns False bool("")==False hope I helped
17th Oct 2016, 6:54 AM
Sunera
Sunera - avatar
- 3
andrid@system.com
17th Oct 2016, 3:52 AM
robby.h
- 3
01010110110110011000
17th Oct 2016, 3:53 AM
robby.h