# Lambda function in list

**URL:** <https://forum.codewithmosh.com/t/lambda-function-in-list/29963>\
**Category:** Python\
**Created:** [November 15, 2024, 10:37am UTC](https://forum.codewithmosh.com/t/lambda-function-in-list/29963 "2024-11-15T10:37:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MariaK](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@MariaK](https://forum.codewithmosh.com/u/MariaK)\
**Post date:** [November 15, 2024, 10:37am UTC](https://forum.codewithmosh.com/t/lambda-function-in-list/29963/1 "2024-11-15T10:37:28Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![silentway](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@silentway](https://forum.codewithmosh.com/u/silentway)\
**Post date:** [November 26, 2024, 3:35pm UTC](https://forum.codewithmosh.com/t/lambda-function-in-list/29963/2 "2024-11-26T15:35:59Z")

</div>

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].
