English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
In this program, you will learn to find numbers that can be divided by another number and display them.
To understand this example, you should understand the followingPython programmingTopic:
In the following program, we use an anonymous (lambda) function in the filter() built-in function to find all numbers in the list that can be divided by13Divisible numbers.
# List a series of numbers my_list = [12, 65, 54, 39, 102, 339, 221,] # filter uses an anonymous function result = list(filter(lambda x: (x % 13 == 0), my_list)) # Display result print("Can be divided by"13The numbers that are divisible by "result"
Output result
Can be divided by13The numbers that are divisible by [65, 39, 221]