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 String rstrip()
Python Type Conversion and Type Casting
Python Set remove()
Python Program to Iterate Through Two Lists in Parallel
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python Program to Find Hash of File
Python Program to Sort Words in Alphabetic Order
Python Dictionary
Python Program to Shuffle Deck of Cards
Python Program to Copy a File
Python String rfind()
Python Program to Create a Long Multiline String
Python Program to Find the Factorial of a Number
Python Custom Exceptions
Python frozenset()
Python Set add()
Python Dictionary update()
Python Global Keyword
Python Dictionary clear()
APIs in Node.js vs Python - A Comparison
Python Set copy()
Python @property decorator
Python Program to Find the Square Root
Python Program to Generate a Random Number
Python Set clear()
Python Multiple Inheritance
Python __import__()
Python Set update()
Python len()
Python for Loop
Python Program to Compute all the Permutation of the String
Python time Module