```
class Solution(object):
def productExceptSelf(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
n=len(nums)
r=[None]*n
r[-1]=1
c=1
for i in range(len(nums)-1):
r[-i-2]=r[-i-1]*nums[-i-1]
for i in range(len(nums)):
r[i]=r[i]*c
c=nums[i]*c
return r
```