Page 1 of 1

Python: Checking If Something Typed in or Not

Posted: Fri Oct 24, 2025 6:11 am
by Jason

Code: Select all

name = " "   # Nothing is typed in.

name = bool(name)

# It was originally a string, but now typecasted to a Boolean.

print(name)

# It can only print true or false and it will output false because nothing was typed in, otherwise it would always be true.