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

johnworg
johnworg
1,280 Points

Writing If/else. why does the variable always seem to have a value of None. Would this always be the case? Other exmpls

I have noticed in the course that when we are writing an if/else statements. The variable always seems to have a value of None. Why is this? Are there situations where it would have another Value? What would some other examples look like?

EX from course: store_open = None

Thank you for your time.

1 Answer

Steven Parker
Steven Parker
229,785 Points

:point_right: The challenge you linked to provides a good example.

In that challenge, you are asked to construct an if/else that will set the value of store_open to either True or False. There is no condition where it is set to None.

As you progress in the course, you will find that None can be useful sometimes, but it will not be used in the majority of situations.