Lambda function in list

v = [1, 2, 3]

def g(a, b, m):
return m(a, b)

print(g(1, 1, lambda x, y : v[x : y + 1]))

output is [2] , can someone please explain how we get output [2]

I’m not sure which part of this you are struggling with … but you are basically evaluating v[1:2]. This is a list slice. The slice starts at index 1 and goes up to (but does not include) index 2. Hence [2].