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 trialCorey Schroeder
12,281 PointsIs using "continue" necessary?
The instructor is using "continue" to "move on to the next step of the loop". Is this necessary? My program seems to run as expected without that line on either the "SHOW" or "HELP" portions of the loop.
If someone could lend some additional information on this - specifically why its working without that information, and why I may want to add it into my code - it would be greatly appreciated.
Thank you!
3 Answers
Jennifer Nordell
Treehouse TeacherHi there! My guess here is that you haven't tried all possible scenarios without the continue. I encourage you to try commenting out the continue at SHOW part. When you do that and start the program, then immediately enter SHOW here's what happens:
> SHOW
Here's your list:
Added SHOW. List now has 1 items.
Because the continue would force it back up to the top of the loop and skip over adding the item "SHOW". But because it's now commented out, that doesn't happen so it actually gets added to the list. Hope this makes sense!
Sneha Nagpaul
10,124 PointsMaybe you are not using elif statements but rather separate if statements.
Allison Schaaf
33,322 PointsYou don't need to use continue since you're appending to the list in an else block.
Corey Schroeder
12,281 PointsCorey Schroeder
12,281 PointsI don't seem to have that issue. No matter what combo of entries I've tried, including your suggestion, I can't duplicate that issue.
Here is the code of the main loop:
Note, I coded this during the "pause and see if you can figure it out yourself..." section. The only part I added after watching the video was the "verification" line of code that displays the item you added and your current number of items. Perhaps my version (though I don't think its very different from the instructor's) prevents this from happening...?
I appreciate your help!