“пересечение списков в Python” Ответ

пересечение двух списков Python

>>> a = [1,2,3,4,5]
>>> b = [1,3,5,6]
>>> list(set(a) & set(b))
[1, 3, 5]
batman_on_leave

пересечение в списке

def intersection(lst1, lst2): 
    lst3 = [value for value in lst1 if value in lst2] 
    return lst3 
  
# Driver Code 
lst1 = [4, 9, 1, 17, 11, 26, 28, 54, 69] 
lst2 = [9, 9, 74, 21, 45, 11, 63, 28, 26] 
print(intersection(lst1, lst2)) 
Victorious Vendace

пересечение списков в Python

import numpy as np
recent_coding_books =  np.intersect1d(recent_books,coding_books)
Frail Falcon

пересечение двух списков Python

# Python program to illustrate the intersection
# of two lists in most simple way
def intersection(lst1, lst2):
	lst3 = [value for value in lst1 if value in lst2]
	return lst3

# Driver Code
lst1 = [4, 9, 1, 17, 11, 26, 28, 54, 69]
lst2 = [9, 9, 74, 21, 45, 11, 63, 28, 26]
print(intersection(lst1, lst2))
Africodes

Python получить пересечение двух списков

# intersection of two lists (lst1 & lst2)
In [1]: x = ["a", "b", "c", "d", "e"]

In [2]: y = ["f", "g", "h", "c", "d"]

In [3]: set(x).intersection(y)
Out[3]: {'c', 'd'}
# has_intersection = bool(set(x).intersection(y)) -> True
gdfelt

Ответы похожие на “пересечение списков в Python”

Вопросы похожие на “пересечение списков в Python”

Больше похожих ответов на “пересечение списков в Python” по TypeScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования