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.
# 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)
Comments
Leave a comment