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 trialhenry duquesnay
6,976 PointsWhy use a Tuple for Shopping List App??
I know this was probably an example of how to clean up code or something, and I know my understanding of coding is still early on, but why use a Tuple for this shopping list app?
I just remember that one of the shopping list app features was to be able to assign index values. If Tuples are immutable, doesn't this defeat the purpose of that feature and those lines of code -- to be able to move items around?
Just making sure i'm understanding, because i don't see how that code cleanup helped.
1 Answer
Josh Keenan
20,315 PointsThe tuple is being used to store constant values, the flask basics course is 189 minutes long, that won't change therefore a tuple is your best suited option. With the shopping list app, prices are probably going to be fixed and storing them in tuples in pairs of item, price. The tuples are then stored in a list so the items can be moved and shifted, but their name and price will be fixed.