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 Data Structures and Algorithms - Benjamin Baka
Python if...else Statement
Python List remove()
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli
Python Program to Represent enum
Python Program to Shuffle Deck of Cards
Python property()
Python String index()
Python help()
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python Program to Slice Lists
Python Set remove()
Deep Learning with Applications Using Python - Navin Kumar Manaswi
Python String lstrip()
Python String isnumeric()
Python Set difference_update()
Python List pop()
Python Program to Print all Prime Numbers in an Interval
Python Program to Display the multiplication Table
Python Dictionary popitem()
Python String isidentifier()
Python setattr()
Java Program to Implement the Program Used in grep/egrep/fgrep
Python iter()
Python exec()
Python Input, Output and Import
Python String format_map()
Python ascii()
Python all()
Python sorted()