2 Replies - 241 Views - Last Post: 05 May 2013 - 09:56 PM Rate Topic: -----

#1 tina9899  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • D.I.C Head

Reputation: 116
  • View blog
  • Posts: 212
  • 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  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7561
  • View blog
  • Posts: 12,678
  • 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