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

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

William CHOE
William CHOE
788 Points

Position question

I have some problems understanding the part,which Kenneth use the input by variable"position" , when i press ENTER , what did the function return ? Is it NONE? or something else? can someone help me out?

1 Answer

Jakob Hansen
Jakob Hansen
13,746 Points

when you press enter, you just enter a "new line character" to the input, but it doesn't really matter what you entered, it could have been any non-integer in this case, because the except clause gets run when you press enter ( or any non-integer value, because we get a valueError, we didn't enter a number,) and we set position to None, then in the else clause, we just append the item, and append adds the item to the end of the list.