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 Membership

[SOLVED] What am I doing wrong in my if else statement in Python?

The question asks to set a certain variable to True if a condition is met. Else set it to false. I am setting the variable to a value such that the condition for True is met. So obviously the Else statement fails and the variable is not set to False. But the automated code check doesn't pass my code.

Ken Alger
Ken Alger
Treehouse Teacher

Welcome to Treehouse!

Can you post the code you are using? It might be a small syntax error.

Thanks,
Ken

Ken Alger
Ken Alger
Treehouse Teacher

Edited for [solved].

2 Answers

I figured it out. I was creating the variable and adding a value to it, before the if/else statements, so only one condition was getting tested.

Thanks for offering to help!