# 13/15 plz help rint ur code so i can compare plz here is mine

#1

``````def product(x):
total = 1
for i in range(len(x)):
total = total * x[i]

number_list = [1, 2, 3, 1, 10 ]
print product(number_list)

choose = str(raw_input("What are your numbers: "))``````

#2

Indenting is crucial in Python.

Any lines of code that you want to have included in your product function must be indented. In the following image, because you stopped indenting, `total = 1` is the last line of your function.

#3

The above code seems needlessly overcomplicated
here's my two cents:

``````def product(numbers):
total = 1
for i in numbers:
total *= i

or an even shorter version:

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

#4

Hey, how can i get my raw input to take more than 1 number: It returns an error if i try entering more than 1 number....Thanks!

```def product(numbers):
total = 1
for n in numbers:
total *= n

numbers = str(raw_input("What are your numbers: "))
print product(numbers)```

#5

#6

I've tried it by making the `total = 0`, it was a challenge lol, managed to get it working though,
this is what I came up with:

``````def product(uInput):
total = 0
length = len(uInput)
if length <= 1:
total = uInput[0]
elif length <= 2:
total = uInput[0] * uInput[1]
else:
total = uInput[0] * uInput[1]
uInput.pop(0)
uInput.pop(0)
for j in uInput:
total = total * j

print product([4,5,5])``````

#7

thanks marmaa...good code here..

#8

@Pislarm
If you want to do that here is my solution but it is in python 3x should still work in python 2x with a small bit of fiddling

``````  def product(numbers):
total = 1
for i in numbers: total*=i
print("Product of",numbers,)
print("Is :",total,)

def getinput():
userInput = input("Enter String of numbers \
seperated by spaces\n :> ")
print("\n")
chngNum = map(int, userInput.split())
numbers= []
for i in chngNum: numbers.append(i)
return numbers

product(getinput())``````

#9

Here's how I did it

def product(sequence):
result = 1
sequence = list(sequence)
for i in sequence:
if i == int(i):
result *= i
else:
break
return result