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 trialDaniel McFarlin
5,168 PointsHow do I share my workspace code to get help?
I wanna ask where I went wrong on this pretty long bit of code written in workspaces making up the shopping_list_3.py file. Is there a way for me to attach the work to a question so people can actually see the code to help me out and see the error codes popping up? If so that would be great to know.
2 Answers
Alexander Davison
65,469 Pointsjason speziale
656 Pointswhat is wrong with my code
import os Shopping_list = []
def clear_screen():
os.system("cls" if os.name == "int" else "clear")
def show_help():
clear_screen()
print("\nSeparate each item with comma.")
print("Type DONE to quit, SHOW to see the current list, and HELP to get this message.")
def add_to_list(item):
show_list()
if len(shopping_list):
position = input ("where should I add {}?\n"
"press enter to add to the end of the list\n"
"> ".format(item))
else:
postion = 0
try:
postion = abs(int(position))
except valueError:
position = none
if position is not none:
shopping_list.insert(position-1, item)
else:
shopping_list,append(new_item)
show_list()
def show_list():
clear_screen()
print("here's your list:")
index = 1
for item in Shopping_list:
print("{}. {}" .format(index,item))
index += 1
print("-"+10)
show_help()
while True: new_item = input("> ")
if new_item.upper() == 'DONE' or new_item.upper() == 'quit':
break
elif new_item.upper() == 'HELP':
show_help()
continue
elif new_item.upper() == 'SHOW':
show_list()
continue
else:
add_to_list(new_item)
show_list()
Daniel McFarlin
5,168 PointsDaniel McFarlin
5,168 PointsExactly what I needed. You are the best Alexander! :)
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsNo problem