Answer to Question #284868 in Python for hello

Question #284868

Draw a flowchart and construct a python program to accept a list of N numbers. The job is to determine if there exists an element in the list such that the sum of the elements on its left is equal to the sum of the elements on its right. If such element exists, then print the index of the element. If there are no such elements, then the sum is zero. 


1
Expert's answer
2022-01-05T01:40:04-0500
# Python 3.9.5

n_list = input('Enter numbers separate by space: ').split()
n_list = [int(i) for i in n_list]

res = 0
for i in range(0, len(n_list)):
    if sum(n_list[:i]) == sum(n_list[i+1:]):
        res = f'Index: {i}'
print(res)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS