def find_product(lst):
result = []
left = 1 # To store product of all previous values from currentIndex
for i in range(len(lst)):
currentproduct = 1 # To store current product for index i
# compute product of values to the right of i index of list
for ele in lst[i+1:]:
currentproduct = currentproduct * ele
# currentproduct * product of all values to the left of i index
result.append(currentproduct * left)
# Updating `left`
left = left * lst[i]
return result
Can you explain how come the line for ele in lst[i+1:]: did not go out of index during the last iteration of the our for loop?
Course: Educative: Interactive Courses for Software Developers
Lesson: Educative: Interactive Courses for Software Developers