# Adding lists in a function

Page 1 of 1

## 2 Replies - 357 Views - Last Post: 05 May 2013 - 09:56 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=320359&amp;s=f329c66cf6fffa9f9a45506ee3cac63a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 tina9899

• New D.I.C Head

Reputation: 0
• Posts: 3
• Joined: 15-April 13

# Adding lists in a function

Posted 05 May 2013 - 03:10 PM

I want to add two list and then put the new values in a third array. Then find the average of the values in the third array. I cant make any changes to the main function. Just write the function definitions for add_lists and average_list. Here's my code:

```def main():
numbers1 = [8, 4, 6 , 10, 2]
numbers2 = [1, 3, 5, 7, 9]

numbers3 = add_lists[numbers1, numbers2]

print('the sum of the two lists is')
display(numbers3)

average = average_list(numbers3)
print('The average value is', average)

input('press enter to continue')

```

This post has been edited by macosxnerd101: 05 May 2013 - 05:45 PM
Reason for edit:: Please use code tags

Is This A Good Question/Topic? 0

## Replies To: Adding lists in a function

### #2 Mekire

Reputation: 118
• Posts: 216
• Joined: 11-January 13

## Re: Adding lists in a function

Posted 05 May 2013 - 08:54 PM

I really think this line in the main function:
```numbers3 = add_lists[numbers1, numbers2]
```
is supposed to be this:
```numbers3 = add_lists(numbers1, numbers2)
```

But other than that, it seems you haven't made an attempt yet. Generally just posting the assignment problem will not get you much help. Also what do you mean by add lists? Make one list by concatenating them; add the values together; who knows?

-Mek

### #3 jon.kiparsky

• Pancakes!

Reputation: 8430
• Posts: 14,527
• Joined: 19-March 11

## Re: Adding lists in a function

Posted 05 May 2013 - 09:56 PM

So you have your assignment in front of you. What are you going to do about it?