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
1 2 3 4 5 6 7 8 | # 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
1 | Numbers divisible by 13 are [ 65 , 39 , 221 ] |
Related posts:
Python List clear()
Python String title()
Python List reverse()
Python Program to Display Calendar
Python String encode()
Python set()
Python Objects and Classes
Python Program to Find the Sum of Natural Numbers
Python String center()
Python Program to Merge Two Dictionaries
Python break and continue
Python Set symmetric_difference()
Python Program to Swap Two Variables
Python Strings
Python abs()
Python next()
Python Program to Convert String to Datetime
Python Program to Check If a String Is a Number (Float)
Python Generators
Python Set intersection_update()
Python hash()
Python Decorators
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Python Program to Display Fibonacci Sequence Using Recursion
Python Functions
Python Data Types
Python Program to Print Output Without a Newline
Python format()
Python String translate()
Python list()
Python oct()
Python Program to Check if a Key is Already Present in a Dictionary