Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Does 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.
Steven Parker216,810 Points
You 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.