Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Logic in Python Conditional Value

Hi I'm not sure I totally understand the challenge. for setting a variable to true or false using boolean logic.

If admitted has been assigned to false (i.e. none), How do I reassign it to become true. I had attempted to reassign to age which worked but when I wanted to include the else statement, the first code became invalid. Would appreciate any insight on this.

conditions.py
admitted = None
if age>=13:
    admitted =bool(1)
    else admitted = bool(0)

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,862 Points

Hi Ifeoma,

While it is true that bool(1) evaluates to True. It's better practice to just assign True directly:

admitted = True

As for your invalid code, this is because your else statement is at the wrong indentation level. else should always be indented at the same level as its corresponding if.

Cheers

Alex