Prerequisite : Lambda in Python
Given a list of numbers, find all numbers divisible by 13.
Input : my_list = [12, 65, 54, 39, 102, 339, 221, 50, 70] Output : [65, 39, 221]
We can use Lambda function inside the filter() built-in function to find all the numbers divisible by 13 in the list. In Python, anonymous function means that a function is without a name.
The filter() function in Python takes in a function and a list as arguments. This offers an elegant way to filter out all the elements of a sequence “sequence”, for which the function returns True.
[65, 39, 221]
Given a list of strings, find all palindromes.
['geeg', 'keek', 'aa']
Given a list of strings and a string str, print all anagrams of str
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.