Why didn't my boolean work?



I wrote my code for the boolean and when I press Run it isn’t accepted; why is this?


Python, and all programming languages, require you to match their syntax exactly. Note that there are no quotation marks around a boolean value, and that they are capitalized. In other languages you may see booleans written as true and false, but in Python they must be True and False. Keep that in mind for future exercises where you’ll be asked to check if something is True or False so you don’t compare to a string, like ”True”!

Take a look at the code below for a better understanding:

bool_1 = True
bool_2 = False
bool_3 = true     # invalid
bool_4 = false    # invalid
bool_5 = "true"   # invalid
bool_6 = "false"  # invalid

FAQ: Learn Python - Python Syntax - Booleans

I just started learning python today so not exactly an expert, but what I noticed is that this program is somewhat strict. you have to write True or False, the capital letters seem important for the first letters. So you cannot write tRue, trUe, truE, TruE and so on…