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…


i used lower case for false and it ran fine but only accepted capitalised true ???


If True corresponds with number 1 why is name_is_maria = 1 incorrect; for age_is_12 I typed age_is_12 = 0 which worked.


I have the same question, can someone advice please?


i have the same question!
can someone help me get the answer?


Entering name_is_maria = 1 assigns the value one to your variable called name_is_maria, just as if you used = 2, =10, = 15.5, or any other value. Instead, you want to assign it a value of True or False.
After assigning it a value of True, I then entered name_is_maria += 3 to add three to the stored value of True and 1. The print function then returned the value 4 for me, which demonstrates that the name could be True and have the integer value of 1.


Thanks for your advice!! Really helped me.