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 trialmahesh gurbaxani
1,420 Pointswhere have I gone wrong?
Please help.Thanks
# add_list([1, 2, 3]) should return 6
# summarize([1, 2, 3]) should return "The sum of [1, 2, 3] is 6."
# Note: both functions will only take *one* argument each.
number_list=list()
def show_num():
print("whats your number or 0 to quit")
def add_list(new_num):
number_list.append(new_num)
def show_total():
for new_num in number_list:
new_num+=num
print(num)
while True:
if new_num == "0":
show_total()
break
add_list(new_num)
continue
show_num()
1 Answer
Katy Goodman
16,311 PointsI think at the beginning you are trying to initialize a new list? If so, you should do that like this:
number_list = []
Also, your function names don't seem to line up with what the functions are actually doing. For example, your function show_num seems like it should print a number to the console, but instead you ask the user for a number, and then don't follow up with a way for the user to input a number.
You are also missing the function "summarize" which should "sum up" what your add_list function just did...
It seems like the while loop is also unnecessary for this assignment.
Joshua Ferdaszewski
12,716 PointsJoshua Ferdaszewski
12,716 PointsOne thing that I see right away is that you have issues with indentation and white space. Spaces/tabs hold syntactic importance in Python, as they show what parts of your code are in specific function or while loops for example. Looking at your code it is not apparent what this program is trying to accomplish.