hw 3.3: What should the code end with exactly?

Hi, confident to have the correct solution for the product list. However, I feel uncertain what the code should terminate with? My 3 considerations:

  1. simply "return i" which computes the value
  2. "product_list"
  3. "print product_list
  4. Using one of the examples "print product list ([1,2,3,4])"

Would be devastated to get it graded "incorrect" just because of this ...

asked 10 Mar '12, 13:15

newcoder's gravatar image

newcoder
04

accept rate: 50%

edited 10 Mar '12, 13:16


3 Answers:

Read the top comments, carefully...
#and returns a number that is
#the result of multiplying all
#those numbers together.

Emphasis added for clarity! Do not over-think it, return means just that, return

link

answered 10 Mar '12, 13:21

Angel's gravatar image

Angel
7.1k632112

edited 10 Mar '12, 13:23

def product_list(pr_list):
    #
    # some code
    #
    return the_answer

link

answered 10 Mar '12, 13:27

Rob%20Barnes-3's gravatar image

Rob Barnes-3 ♦
19.3k1068205

i think it will be wrong if you just print it from the function - it needs to be returned before printing

link

answered 10 Mar '12, 13:18

wobbly-1's gravatar image

wobbly-1
30241326

Your answer
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags

×29,647
×1,798
×46
×10

Asked: 10 Mar '12, 13:15

Seen: 183 times

Last updated: 10 Mar '12, 13:27