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.

Python Python Collections (2016, retired 2019) Lists Shopping List Take Three

Show list

Why did he place the show_list() at the beginning of add_to_list() function. It will first show list and then add that contemporary item to the list. So the list shown will be incomplete, won't it be?

1 Answer

Francesc Box
Francesc Box
1,637 Points

He did that because now we ask user in which position to insert the new item.

So, before asking where to insert, it's nice to show current items and their position, so user can decide. Otherwise, user should remember the list components and positions by heart.