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 Catch Multiple Exceptions in One Line
Python Program to Capitalize the First Character of a String
Python String lower()
Python Program to Trim Whitespace From a String
Python Program to Generate a Random Number
Python Program to Find LCM
Python iter()
Python Program to Check if a Number is Odd or Even
Python min()
Python Program to Check if a Number is Positive, Negative or 0
Python Input, Output and Import
Python Program to Check Whether a String is Palindrome or Not
Python Set intersection()
Python Program to Make a Simple Calculator
Python Program to Swap Two Variables
Python List copy()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python Program to Find Armstrong Number in an Interval
Python Program to Create a Long Multiline String
Python Program to Convert Bytes to a String
Python type()
Python Tuple
Python Set difference()
Python Global Keyword
Python Program to Convert Kilometers to Miles
Python String count()
Python Program to Count the Number of Each Vowel
Python String isidentifier()
Python Program to Get the Full Path of the Current Working Directory
Python String isprintable()
Python Shallow Copy and Deep Copy
Python sum()