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 trialSebastiaan van Vugt
Python Development Techdegree Graduate 13,554 PointsDoes pass do the same as continue?
Instead of continue I tried to use pass in a while loop. Even though it runs it doesn't seem to do anything. Is it right that pass and continue are equivalent but that pass should be used in a for loop and continue in a while loop?
Thanks for insights on this matter.
1 Answer
Steven Parker
231,236 PointsYou can use "continue" in any kind of loop, but it cannot be used outside of a loop. It causes the loop to repeat immediately without waiting until the the current iteration completes. It might appear to be doing nothing if it's at the end of the loop.
On the other hand "pass" can be used in or out of loops. It serves only as a placeholder and doesn't do anything.
Sebastiaan van Vugt
Python Development Techdegree Graduate 13,554 PointsSebastiaan van Vugt
Python Development Techdegree Graduate 13,554 PointsThanks a lot. I thought that pass could also interfere with the loop but now noticed that indeed it actually does not.