I have a list of items. I want to replace first item with product of remaining items of list except first. Do the same for remaining all. How can i do that?
lst = [2,3,5,4,7]
Output should be :
New_lst = [420,280,168,210,120]
First get the product:
>>> import math
>>> p = math.prod([2,3,5,4,7])
>>> p
840
Then divide all numbers by the product:
>>> lst = [2,3,5,4,7]
>>> New_lst = [p//i for i in lst]
>>> New_lst
[420, 280, 168, 210, 120]