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 extra credit problem
i did the extra credit for the shopping list project but when i check the file i created for the list, the list horizontal not vertical like a list, how can i make it vertical?
Freddy Venegas1,226 Points
I did this like so,
def open_save(): with open('list.txt', 'w') as l: for items in shopping_list: l.write(str(items) + "\n")
and that seemed to work. By adding the "\n" you create a new line.
Out of curiosity, how did you get the contents from the file to read into your list when the file first runs? I am stuck on that step.
What does your print statement look like?