# Adding lists in a function

Page 1 of 1

## 2 Replies - 703 Views - Last Post: 05 May 2013 - 09:56 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=320359&amp;s=8937e55ba968e714a3c051099f85e9e9&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

• D.I.C Head

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
Was This Post Helpful? 0

### #3 jon.kiparsky

• Beginner

Reputation: 11041
• Posts: 18,856
• 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?
Was This Post Helpful? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }