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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![mohan Abdul](https://secure.gravatar.com/avatar/c2d82f960291404a11c9a865db4a0a92?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
mohan Abdul
Courses Plus Student 1,453 Pointsthe teacher he could have added '''add_to_list''' to an else statement, but it meant that he wouldn't able to show me t
the teacher he could have added '''add_to_list''' to an else statement, but it meant that he wouldn't able to show me the '''continue''' function. Can anyone please show me it would have looked like if the teacher used else statement please?
1 Answer
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsBy extending the if
statement with the code:
else:
add_to_list(new_item)
the if
statement becomes the last code within the while
block. Therefore it will not matter if the continue
statements remain. In either case, the code will jump back to the top of the while
loop. Since, it doesn’t matter, the continue
statements should be removed to simply the code.
Post back if you need more help. Good luck!!!
mohan Abdul
Courses Plus Student 1,453 Pointsmohan Abdul
Courses Plus Student 1,453 Pointsin your python code, could you please include were break and continue would have been. I'll copy and paste the code here so save you from typing it from scratch.
Chris Freeman
Treehouse Moderator 68,425 PointsChris Freeman
Treehouse Moderator 68,425 PointsOriginal code:
becomes
mohan Abdul
Courses Plus Student 1,453 Pointsmohan Abdul
Courses Plus Student 1,453 Pointshi, on both the ''elif'' statements its missing the key word '''continue''', on typing '''SHOW''' & '''HELP''' wouldn't it add SHOW & HELP onto the list? As in the original code with out continue it added them to the list.
Chris Freeman
Treehouse Moderator 68,425 PointsChris Freeman
Treehouse Moderator 68,425 PointsIn an
if/elif/else
statement, only exactly one code block will execute. Since the add is in theelse
block, it will only execute if none of the preceding conditions are met.The next line to execute after
show_help
orshow_list
will be thewhile
statement.