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. 


Expert's answer

# 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!

LATEST TUTORIALS
APPROVED BY CLIENTS