In this program, you’ll learn to find the numbers divisible by another number and display it.
To understand this example, you should have the knowledge of the following Python programming topics:
In the program below, we have used anonymous (lambda) function inside the filter() built-in function to find all the numbers divisible by 13 in the list.
Source Code
# Take a list of numbers
my_list = [12, 65, 54, 39, 102, 339, 221,]
# use anonymous function to filter
result = list(filter(lambda x: (x % 13 == 0), my_list))
# display the result
print("Numbers divisible by 13 are",result)
Output
Numbers divisible by 13 are [65, 39, 221]
Related posts:
Python repr()
Python Program Read a File Line by Line Into a List
Python all()
Python Program to Count the Number of Digits Present In a Number
Python Directory and Files Management
Python datetime
Python Dictionary
Python classmethod()
Python Program to Transpose a Matrix
Python File I/O Operation
Python String center()
Python String splitlines()
Python ord()
Python Set discard()
Python Dictionary setdefault()
Python Program to Make a Flattened List from Nested List
Python Program to Check If a List is Empty
Python List clear()
Python String expandtabs()
Python String title()
Python RegEx
Python Set intersection_update()
Python Program to Convert Celsius To Fahrenheit
Python String startswith()
Python min()
Python String rfind()
Python Program to Get File Creation and Modification Date
Python frozenset()
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python String upper()
Python String rjust()
Python Variables, Constants and Literals