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 zip()
Python float()
Python Set issuperset()
Python Program to Create a Countdown Timer
Python Program to Concatenate Two Lists
Python Program to Differentiate Between type() and isinstance()
Python Program to Convert Kilometers to Miles
Building Machine Learning Systems with Python - Willi Richert & Luis Pedro Coelho
Python String endswith()
Python Program to Get a Substring of a String
Python Program to Iterate Over Dictionaries Using for Loop
Python Program to Find All File with .txt Extension Present Inside a Directory
Python Program to Randomly Select an Element From the List
Python Program to Check the File Size
Python String ljust()
Python Program to Get the Full Path of the Current Working Directory
Python Program to Find the Largest Among Three Numbers
Python 3 for Absolute Beginners - Tim Hall & J.P Stacey
Python Matrices and NumPy Arrays
Python abs()
Python List reverse()
Python Program to Calculate the Area of a Triangle
Python String maketrans()
Python String rfind()
Python Function Arguments
Python chr()
Python print()
Python Program to Print all Prime Numbers in an Interval
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python Program to Compute the Power of a Number
Python Directory and Files Management
Python Set remove()