# Write a Python function to create a new array such that each element at index i of the new array is the product of all the numbers of a given array of integers except the one at i.

## Topic: Write a Python function to create a new array such that each element at index i of the new array is the product of all the numbers of a given array of integers except the one at i.

Solution

def product(nums): new_nums = [] for i in nums: nums_product = 1 for j in nums: if j != i: nums_product = nums_product * j new_nums.append(nums_product) return new_nums

List all Python Programs