## 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!

### 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###### marwanbakr

2,942 Points# I don't get this at all :/

What am I supposed to do here? I have no clue.

## 2 Answers

###### MUZ140889 Dephine Chenayi Chihota

6,766 Pointshie marwanbakr. okay let me take you through the challenge step by step. task 1

- am sure by now you know how to define a function so according to the first statement you need to define a function called add_list that takes a list of numbers, which is def add_list(a_list):. note well I used the parameter a_list, using list my give you problems since list is a built in function that already exists in python. don't forget to put :
- now we create the variable total that is going to hold the sum of the numbers in the list. we initialize our variable total by setting it to zero. total = 0
- thirdly we use a for loop to add the numbers in our a_list, for number in a_list:
- then add that number to our variable total. this loop iterates through our list adding every number in a_list to the variable total. don't forget to indent this line so that it goes inside the for loop, total = total + number.
- finally we return our total. note well, you should check your indentation very well. be carefull not to put your return inside the for loop. your return should be inline with the for for the for loop.

def add_list(a_list):

total = 0

for number in a_list:

```
total = total + number
```

return total

task 2

- we go through all the steps in task 1 again but now we return the string version of it i.e the sentence. we use the .format function to replace the curly braces with values we want. return "the sum of {} is {}".format(a_list,total) try following this code

def summarize(a_list):

```
total = 0
for number in a_list:
total = total + number
return "The sum of {} is {}.". format(a_list,total)
```

NB: pay special attention to indentation, parenthesis() and the colon: I hope this helps. get back to me if you have any problems.

###### MUZ140889 Dephine Chenayi Chihota

6,766 Pointshie marwanbakr. okay let me take you through the challenge step by step.

task 1

- am sure by now you know how to define a function so according to the first statement you need to define a function called add_list that takes a list of numbers, which is def add_list(a_list):. note well I used the parameter a_list, using list my give you problems since list is a built in function that already exists in python. don't forget to put :
- now we create the variable total that is going to hold the sum of the numbers in the list. we initialize our variable total by setting it to zero. total = 0
- thirdly we use a for loop to add the numbers in our a_list, for number in a_list:
- then add that number to our variable total. this loop iterates through our list adding every number in a_list to the variable total. don't forget to indent this line so that it goes inside the for loop, total = total + number.
- finally we return our total. note well, you should check your indentation very well. be carefull not to put your return inside the for loop. your return should be inline with the for for the for loop.

def add_list(a_list):

total = 0

```
for number in a_list:
total = total + number
return total
```

task 2

- we go through all the steps in task 1 again but now we return the string version of it i.e the sentence. we use the .format function to replace the curly braces with values we want. return "the sum of {} is {}".format(a_list,total) try following this code

def summarize(a_list):

total = 0

for number in a_list:

```
total = total + number
```

return "The sum of {} is {}.". format(a_list,total)

NB: pay special attention to indentation, parenthesis() and the colon: I hope this helps. get back to me if you have any problems.

###### MUZ140889 Dephine Chenayi Chihota

6,766 Pointsdon't forget to upvote

###### MUZ140889 Dephine Chenayi Chihota

6,766 Pointsdon't forget to upvote

## Gloria Dwomoh

13,116 Points## Gloria Dwomoh

13,116 PointsWhich question are you on?