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 (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,703 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.