Converting different data types into each other
Converting different data types into each other
my_boolean = bool("Hello")
print(my_boolean)
When I run this code in python, the output is True.What is the reason?
Strictly speaking you're not converting a value from string to boolean, because you're loosing information, "hello" as input would result in the same output as "bye bye".
– Bouke
Aug 25 at 18:03
1 Answer
1
Because it checks if the string is empty:
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Possible duplicate of stackoverflow.com/questions/18491777/…
– Daniel Mesejo
Aug 25 at 15:38