Skip to content

Commit 738115a

Browse files
authored
Merge pull request powerexploit#27 from noobdev59/master
Sum of all numbers except current index
2 parents 9755c64 + b17b421 commit 738115a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Scripts/sum_lst_index.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# this is a python program to find the sum of all numbers in the list except the current index
2+
3+
4+
5+
from functools import reduce
6+
7+
input_array = input("Please enter the array....\n")
8+
print("Multiplication started.....\n")
9+
10+
original_array = list(map(int, input_array.split(' ')))
11+
12+
lst_to_multiply = []
13+
new_lst = []
14+
15+
for i in range(0,len(original_array)):
16+
if i != 0 and i != len(original_array):
17+
lst_to_multiply = original_array[0:i] + original_array[i+1:]
18+
if i == 0:
19+
lst_to_multiply = original_array[i+1:]
20+
if i == len(original_array):
21+
lst_to_multiply = original_array[0:len(original_array)-1]
22+
# print("lst_to_multiply>>>>", lst_to_multiply)
23+
new_lst.insert(i, reduce((lambda x,y: x * y), lst_to_multiply))
24+
25+
print("NEW_LST", new_lst)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy