Beyond Basics: Advanced Data Handling with Python's operator.itemgetter and Lambda
Extracting First Elements from Sublists.
item1 = [['a', 1], ['b', 2], ['c', 3], ['d', 4]]
list(map(operator.itemgetter(0), item1)) # ['a', 'b', 'c', 'd']
# Using Lambda
list(map(lambda x: x[0], item1)) # ['a', 'b', 'c', 'd']
Extracting Last Eleme...
monojit13.hashnode.dev3 min read