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 trialConrad Cortes
8,418 PointsShopping list help...
I made my own shopping list a little different from the video lesson showed and I can't figure out how to get my list count to start at 1 and not 0 when I make the first entry.
shopping_list = []
print("What should we pick up at the store? ")
print("Enter 'DONE' to stop adding items. ")
print("Enter 'SHOW' to show list")
while True:
new_item = input("> ")
if new_item == 'DONE':
break
elif new_item == 'SHOW':
print(shopping_list)
continue
print("List now has {} items. ".format(len(shopping_list)))
shopping_list.append(new_item)
print("Here's your list: ")
for item in shopping_list:
print(item)
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! Try putting the line with the append
before the line with the print saying how many is in the list. You're printing the length of the list before it has anything in it because you haven't appended yet
Hope this helps!
Conrad Cortes
8,418 PointsThanks a lot! That makes sense and it worked!