How to convert boolean to string in Python

To convert boolean values to strings in Python, you need to use the str() function.

The str() function is used to convert Python objects of any type to strings. This function can be used on boolean values as follows:

>>> str(True)
'True'
>>> str(False)
'False'

You only need to pass the boolean value you want to convert as an argument to the str() function, and you’re done!

If you need to convert string values back to boolean, you can read this tutorial.

I hope this tutorial is helpful. See you in other tutorials! 👍

Take your skills to the next level ⚡️

I'm sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.