## Error in evaluating homework 3.3 & 3.4

With all possible inputs & conditions I'm getting the expected outputs.
Still for both the questions of homework 3.3 & 3.4 its showing answer incorrect, though its output answer is correct.
When submitting 3.3 the output is --> "Incorrect. Your procedure did not return the correct value for a list of one element." though its returning correct value for one element list.
And the error for 3.4 is --> "Incorrect. Your procedure did not return the correct value for an empty list." though the procedure returns Zero for an empty list.

# Code for 3.3
def product_list(n):
product = 1
length = len(n)
while length != 0:
num = n.pop()
product = num * product
length = length - 1
print product
product_list([1,2,3,6])

# Code for 3.4
def greatest(p):
max = 0
for e in p:
if e > max:
max = e
print max
greatest([1,5,3,9,4,9,10,2,4])


Abulize
012

accept rate: 0%

Anton Golov ♦
13.7k2175174

This was the answer I submitted for 3.4 and got graded as wrong when submitted. Please do point out the mistake if any.

(16 Mar '12, 02:25)

It looks like the problem with 3.3 is that it doesn't "return" the value of the product. In fact, if you print "product_list([1,2,3,6])" from the calling procedure, you'll find that it has the value "None"

Alan Kirschbaum
1.1k1626

k.thanx. Now i got ma mistake. Would have put return instead of print in both the answers.

(16 Mar '12, 02:28)

See my answer above for 3.3. Same thing for 3.4 In addition, your code within the definition block needs to be indented (you probably did this, but it doesn't show up in the code snip that you posted.)

Alan Kirschbaum
1.1k1626

The question asked for a procedure to return the greatest number in the list.
You printed it. As venturaeagle said your indentation is wrong but I assume it is through the posting.

Michael Button
1.5k2731

Question text:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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

×29,264
×1,797
×45
×34