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 trialLuke Bennett
10,265 PointsWhile loops - Around and Around Tutorial
In the around and around tutorial why does the 'while' loop stop when it reaches 1? Why does it not carry on forever? I do not see where it becomes false.
1 Answer
James J. McCombie
Python Web Development Techdegree Graduate 21,199 PointsDo you mean the:
start = 0 while start: print(start) start -= 1
loop?
if so its because of 'truthy' and 'falsey' things. whatever is to the right of the 'while' keyword is evaluated to a true or false value. zero, empty strings, and others are falsey, 1 - 10 are truthy. So the loop runs until start = 0, which means while False, and the loop breaks
James J. McCombie
Python Web Development Techdegree Graduate 21,199 PointsJames J. McCombie
Python Web Development Techdegree Graduate 21,199 Pointsyou can see what is truthy and falsey in the repl, bool(something) will tell you
Luke Bennett
10,265 PointsLuke Bennett
10,265 PointsThat's it!
Ahhh Okay, thank you, I remember the lesson now.
Thank you very much :)