Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Logic in Python Booleans

Senay Berhe
Senay Berhe
7,871 Points

Make a variable named right with a value that's truthy. Then make another variable named wrong with a falsey value.

I did like this but I don't know why it is not working

right = "truthy" wrong = "falsey"

even I tried to append it but it is not working.

booleans.py
right = "True"
wrong = "False"

6 Answers

"true" and "false" are Strings, and are not truthy or falsey.

right = 1  
wrong = 0

The following are considered false (falsey):

  • None
  • False
  • zero of any numeric type, for example, 0, 0L, 0.0, 0j
  • any empty sequence, for example, '', (), []
  • any empty mapping, for example, {}
  • instances of user-defined classes, if the class defines a nonzero() or len() method, when that method returns the integer zero or bool value False

All other values are considered true.

Hello. If possible could you explain why are the variables 1 and 0 are not in between quotes?

right = True
wrong = False
Senay Berhe
Senay Berhe
7,871 Points

Thank you and it works.

Antonio De Rose
Antonio De Rose
20,885 Points

even the below will work

right = "Anton" wrong = ""

right = 10 wrong = 0

right="true" wrong= ""

jonlunsford
jonlunsford
15,480 Points

Senay: What you did was add a string to each variable by inlcuding the quotes. A string is different than True / False. Try something like this.

'''python right = True wrong = False '''

jonlunsford
jonlunsford
15,480 Points

ignore the '''python ''' > the markdown did not work apparently. Just use

right = True wrong = False