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 format()
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...
Python Keywords and Identifiers
Python Program to Get File Creation and Modification Date
Python Program to Catch Multiple Exceptions in One Line
Python String rsplit()
Python Program to Count the Occurrence of an Item in a List
Python Program to Remove Punctuations From a String
Python String upper()
Python Program to Find LCM
Python Program to Delete an Element From a Dictionary
Python Program to Print the Fibonacci sequence
Python oct()
Python exec()
Python Program to Check If Two Strings are Anagram
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python Global Keyword
Python String count()
Python Program to Calculate the Area of a Triangle
Python pow()
Python Machine Learning Eqution Reference - Sebastian Raschka
Python max()
Python String isupper()
Python while Loop
Python String replace()
Python Program to Check if a Number is Positive, Negative or 0
Python Program to Compute all the Permutation of the String
Python type()
Python String rstrip()
Python classmethod()
Python staticmethod()
Python strptime()