Question: How is work the function ? Please explain step by step . Why is the output 20 ?Thanks in advance . def mystery(lst): total =
How is work the function ? Please explain step by step . Why is the output 20 ?Thanks in advance .
def mystery(lst):
total = 0
n = len(lst)
for i in range(n):
for j in range( i+1,n):
total += sum (lst[i:j])
return total
lst=[1,2,3,4]
print(mystery(lst))
output is 20
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
