English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python basic tutorial

Python flow control

Funções do Python

Tipos de Dados do Python

Python file operations

Python objects and classes

Python date and time

Advanced knowledge of Python

Python reference manual

Python program to find numbers that can be divided by another integer

Python example大全

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.

Source code

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

Python example大全