每次循环浅拷贝A数组切片,结果数组对应索引位置进行乘积赋值操作

class Solution:
    def multiply(self , A: List[int]) -> List[int]:
        # write code here
        ans=[1 for _ in range(len(A))]
        for i in range(len(A)):
            mark=A[:i]+A[i+1:]
            for item in mark:
                ans[i]*=item
        return ans