Anyone can help me with this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Anyone can help me with this?

#py a= "False" b="True" if bool(a)==bool(b): print(bool(a)) print(bool(b))

6th Jan 2021, 3:20 PM
Surkhab Khan
Surkhab Khan - avatar
2 Answers
+ 2
Boolean value of a string will be False only if your string is empty. This applies to lists, tuples, dictionaries, sets too.
6th Jan 2021, 3:49 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 1
Surkhab Khan You've used the string data type instead of the boolean data type, which doesn't include the quotes. Any value other than None (which includes ""), False or 0 returns True. Try using them without the quotes.
6th Jan 2021, 4:48 PM
Calvin Thomas
Calvin Thomas - avatar