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 trial

Python Python Basics (Retired) Putting the "Fun" Back in "Function" Functions

reza sajadian
reza sajadian
718 Points

I dont know how to add the items to the "summarize" variable

I want to add the list items in the for loop, but i dont know how to do it!

1 Answer

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,735 Points

They want you to create another function called "summarize" - it is not a variable it's a function. This function should return a string using string formatting, and it will use the other function you made as well.

Let me know if you want more hints.

reza sajadian
reza sajadian
718 Points

I did as you said (if I have got you right!) but it still doesn't return the right answer. can you take a look please?

total = 0 also tried with "total = int() " list = [1, 2, 3] def summarize(item): return(total+item)

def add_list(list): for item in list: summarize(item) return(total)

add_list(list)

It says it returns 0! , but the answer should be 6.