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 Program to Convert Two Lists Into a Dictionary
Python Program to Swap Two Variables
Python Program to Create a Long Multiline String
Python Operator Overloading
Python Machine Learning Third Edition - Sebastian Raschka & Vahid Mirjalili
Python Program to Find the Largest Among Three Numbers
Python Program to Print Output Without a Newline
Python List reverse()
Python Dictionary clear()
Python reversed()
Python String replace()
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python Set copy()
Python Dictionary pop()
Deep Learning with Python - Francois Cholletf
Python Function Arguments
Python Set difference()
Python Data Structures and Algorithms - Benjamin Baka
Python String translate()
Python Program to Check if a Number is Positive, Negative or 0
Python zip()
Python type()
Python String isspace()
Python Program to Get the Full Path of the Current Working Directory
Python List copy()
Python Program to Create a Countdown Timer
Python @property decorator
Python String title()
Python Program to Display Fibonacci Sequence Using Recursion
Python String join()
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python property()