This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by lou.brady
over 11 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.

points
Submitted by Pete C.
over 11 years

Answer 50d6b1498d30304ea90035ba

0 votes

Permalink

Should be true, anyway

points
Submitted by M.li
over 11 years

Answer 50f985595872990b260061bf

0 votes

Permalink

the quotation marks must confuse the computer

points
Submitted by William Crutchley
over 11 years