python multiply all elements except ith element in list and return list

  list, multiplication, python

Suppose I have a list .I want to multiply its all elements except with the i’th element.

Example:

  • input: [1,2,3,4]
  • output: [24,12,8,6]

Here, the output

 24 is 2*3*4
 12 is 1*3*4
 8 is 1*2*4
 6 is 1*2*3

Any help would be appreciated

Source: Python Questions

LEAVE A COMMENT