- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayProduct.py
More file actions
Latest commit
30 lines (27 loc) · 576 Bytes
/
Copy patharrayProduct.py
File metadata and controls
30 lines (27 loc) · 576 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
defsol(A):
# p to store the product of array A
p=1;
foriinA:
p=p*i
printp
# p now contains the array product
# creating a new array to output with same length l
outputList=[]
count=0
# have a loop to iterate l(A)
forjinA:
# what if there is a 0 ?
# avoid the divide by zero error; while trying to get the p/A[count]
ifA[count] ==0 :
print"PRINTING"
printA[:count]
printA[count+1:]
print"PRINTING"
outputList.append(p)
else:
outputList.append(p/A[count])
count=count+1
printoutputList
A=[1,3,0,5,6,4]
printA
sol(A)