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 if else loop

I am stuck on task 2 of this code challenge that has dependence on task 1. Anything i change it says Task 1 is no longer passing. I need some help with this.

If this then that video conditional challenge

Challenge Task 2 of 2

OK, one more. Add an else to your if. In the else, set admitted to False.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,468 Points

Can you post your code?

As a general hint, when Task one stops working it usually means a syntax error was introduced when adding code for a later task. You can use the "Go to Task One" button (your code will be safe), then use "Check my work" to see if a better error message is displayed. Good luck!

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,468 Points

The challenge asks to "set admitted to True" so instead of the print statement use:

admitted = True

Don't assign admitted to age. For task 1, he checker is looking for admitted equal to None or True. The checker will assign age to different values during testing.

For Task 2, the next condition considered is non-overlapping with the first can can be handled using and else: statement.

Hi Chris,

Thanks for replying. This was task 1 Challenge Task 1 of 2

I'm going to create a variable named age. I need you to make an if condition that sets admitted to True if age is 13 or more.

My solution:

admitted = None #Given
admitted = age
if age >= 13:
    print(admitted)

So in task 2 to make admitted false again shouldn't the if condition change?

[MOD: added ```python markdown formatting -cf]

Chris Freeman
Chris Freeman
Treehouse Moderator 68,468 Points

Also, it's better for you to respond using comments rather than using "answers" since, once answered, a question gets very few viewers from the Community.

Doh! Thanks that worked.