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 Basics (2015) Shopping List App Refactor

How i can solve the extra credit

Add a "SAVE" option to your script. Use the open function to open a file and save your shopping list to it.

Then use a for loop on the file to read each line in the file. Add each line to your shopping_list variable when your file first runs.

Your list is now more permanent!

I have no idea how work with open. Anyone Please help me

2 Answers

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Extra credit isn't something we validate or anything like that, it's purely work you can do, on your own, to learn more. We have used open() in a few courses, IIRC, but nothing you've done at this point, so I won't refer you to them. But there are links there for the Python docs, so read those and play around. You might be surprised what you can figure out and guess about at this point!

Chris Freeman
Chris Freeman
Treehouse Moderator 67,987 Points

I don't recall a specific Treehouse Python course that covers file input/output. Perhaps Kenneth Love knows better.

There are some hints in the Python Docs on open(). The Python docs also have a tutorial on input and output.