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 trialmarkspenser
Courses Plus Student 256 PointsSame output, without Continue. Why ?
print ('Write something to the list !')
print ('When your done, write: Done')
shoppingList = []
#newItem = input ('Write: ')
while True:
newItem = input ('Write: ')
if newItem == 'Done':
break
shoppingList.append(newItem)
print ('Added ! List has {} items.'.format(len(shoppingList)))
print ('This is your list: ')
for stuff in shoppingList:
print (stuff)
1 Answer
Kenneth Love
Treehouse Guest TeacherBecause the loop is going to continue anyway. The continue
is unnecessary but I included it to point out where the loop restarts.
markspenser
Courses Plus Student 256 Pointsmarkspenser
Courses Plus Student 256 PointsWhen I was trying it for first time, I made that commented statement on line 5. Of course, under while line was just newItem.
So, when it was this way, keyword continue, didn't fix an infinite loop which I made.
P.s.: How do I make text, bold, italic please ?
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest Teachercontinue
can't fix an infinite loop because it just causes the loop to move on to the next step. If there is an infinite number of steps,continue
will happily just keep on moving.Under ever comment box there's a link for the Markdown Cheatsheet. That'll show you how to do formatting in your comments/posts.