Answers for "python print bool as string"

-1

python print bool as string

isFoo = True // our bool variable

// now we use str() to cast bool to string
print('Value of isFoo is: ' + str(isFoo)) // Value of isFoo is: True

// common mistake just for example. Don't do that
print('Value of Foo is: ' + isFoo) // TypeError: can only concatenate str (not "bool") to str
Posted by: Guest on September-24-2020

Code answers related to "python print bool as string"

Python Answers by Framework

Browse Popular Code Answers by Language