0

Why does this statement evaluate to True?

Can someone explain to me how bool() works when only an assignment operator is used? For example: k = " "+" " print(bool(k)) output: True

30th Apr 2018, 12:23 PM
stephanie
stephanie - avatar
3 Respostas
+ 1
blank space hold ascii value of 32 in python hence ur k is not an empty string and any non empty or value less variable passed to bool outputs true
30th Apr 2018, 12:34 PM
Yugabdh
Yugabdh - avatar
+ 1
U can get ascii value of " " using ord function like a =" " b=ord (a) print (b)
30th Apr 2018, 12:43 PM
Yugabdh
Yugabdh - avatar
0
Thank you!!!
30th Apr 2018, 1:26 PM
stephanie
stephanie - avatar