In the collection to filter data based on criteria

In the collection to filter data based on criteria

from random import randint

data = [randint(-10,10) for _ in range(10)]
print(data)
s = set(data)
print(s)

#集合解析来筛选数据
s2 = { x for x in s if x%3 == 0}

Here Insert Picture Description

Published 35 original articles · won praise 2 · Views 2379

Guess you like

Origin blog.csdn.net/qq_31960623/article/details/104226649