13 Product. It does the function, but error still popping up


#1

My function does exactly what they want it do, but still comes up with an error


#2

I'm having the same issue but in another part of the module - maybe this is a site-wide problem?


#3

Ah sorry - my error was that I'd used print instead of return. Sorry to hijack, and good luck!


#4

@wavering_jodi: I tested your code using another compiler and it worked just fine, there was no error caused or anything.
But know that you don't really need to convert into a string so you can iterate over it and append.
Try diving by 10 and getting the remainder of it.

1234 % 10 -> 4
123 % 10 -> 3
12 % 10 -> 2
1 % 10 -> 1

Get those values and start multiplying, you'll see this will actually work as well.
The condition of it could be while n % 10 != 0, continue because 0 % 10 == 0 and so it's true and due to that, you can leave the loop instruction.

Try refreshing the page and executing again!

@coreslayer49537: Try to copy and paste your code into another compiler, such as repl.it , and check if something like that happens as well.
If everything is okay, try refreshing the page and executing again.

Edit: Nevermind the message above, glad you figured it out!


#5

I understand it the best my way and I know it's right, but what can I do?


#6

@wavering_jodi: Not sure if you have to print the return value so if you're still getting some sort of error, after fixing indentation, do print reverse("Python!") .

Edit: Confused the posts, my apologies!


#7

woah, that's a totally different section. I'm on 13 products.


#8

@wavering_jodi: My apologies! I thought the image right above my post was yours, my bad!
But try printing the the return value from it, if you're still getting errors.
Just make sure to follow all the instructions , so you can pass.


#9

it literally did exactly what it was supposed to


#10

def product(number):
total = 1
for i in number:
total *= i
return total


#11

def product(lst):
total = 1
for i in lst:
total = total*i
return total
print product([1,2,3,4])

prints 24