Anonymous/Lambda Functions In Python

Code file as described in the video

# Lambda functions or anonymous functions
# def add(a, b):
#     return a+b
#
# # minus = lambda x, y: x-y
#
# def minus(x, y):
#     return x-y
#
# print(minus(9, 4))


a =[[1, 14], [5, 6], [8,23]]
a.sort(key=lambda x:x[1])
print(a)
  


Comments(1)

sahib007 at 2019-06-23 09:30:09 says
def a_first(a): print(a[1]) a = [[1, 14], [5, 6], [8, 23]] a.sort(key=a_first) print(a) # Harry bhai ye code to run hi ni ho rha h