fastread homefastrread library fastread menu

Python : Find Numbers Divisible by Another Number

Tutorial by:Rizwan Abdullah      Date: 2016-06-16 01:43:29

❰ Previous Next ❱

Source Code


# Python Program to find numbers divisible by thirteen from a list using anonymous function

# 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]

In this program, we have used anonymous (lambda) function inside the filter() built-in function to find all the numbers divisible by 13 in the list.

❰ Previous Next ❱


Python

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website