Skip to content

Python print Boolean as a string | Example code

  • by

Use the str method to print the Boolean value as a string in Python.

str(BooleanValue)

Example print Boolean as a string

Simple python example code.

bool_val = True
print(str(bool_val))

print(type(str(bool_val)))

Output:

Python print Boolean as a string

Use + operator with str()

The advantage of converting a boolean into a string you can concatenating a boolean to a string that appends it to the end of another.

bool_val = True
print("This is: " + str(bool_val))

This is: True

Do comment if you have any doubts and suggestions on this Python Boolean string topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading