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! 👍