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?





Possible duplicate of stackoverflow.com/questions/18491777/…
– Daniel Mesejo
Aug 25 at 15:38





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.

Popular posts from this blog

Malaysia to Papua New Guinea by motorcycle?

.name

List of Bhojpuri films