Profile image of lou.brady
Submitted by lou.brady
about 12 years

Why is it sometimes 'False' or 'True' and others False or True

Why in this section do you sometimes have to write ‘False’ or ‘True’ with quotation marks to Run correctly and others False and True without quotations makrs

2**3 == 108 % 100 or ‘Cleese’ == ‘King Arthur’

bool_one = False

Double check your value for bool_one! Oops, try again.

2**3 == 108 % 100 or ‘Cleese’ == ‘King Arthur’

bool_one = ‘False’

That’s correct! Next Exercise: Not

Answer 50fb12081c9116a6770018b0

1 vote

Permalink

Text in quotes are treated as Strings, while “True” or “False” without the quotations are treated as Boolean variables. They are different data types.

Strings are “string of text” that could be “printed” (output) to the screen, while Booleans are just variables used to store “yes” or “no”. For example:

print "True"

will output “True” (without quotes) to the screen, while

print True

will not. And

x = True
if x == True:
    print "x is true"
else:
    print "x is not true"

will print “x is true” (without quotes) to the screen, while

x = "True"
if x == True:
    print "x is true"
else:
    print "x is not true"

will print “x is not true” (without quotes) because the data type is different.

The system should not let you pass if you put quotes around “True” and “False”, but Codecademy still have some flaws and sometimes does that.

Comments below if you still do not understand.

Profile image of PeteCSH
Submitted by PeteCSH
about 12 years

Answer 50d6b1498d30304ea90035ba

0 votes

Permalink

Should be true, anyway

Profile image of fox235
Submitted by fox235
about 12 years

Answer 50f985595872990b260061bf

0 votes

Permalink

the quotation marks must confuse the computer

Profile image of Claw2012
Submitted by Claw2012
about 12 years