from random import randint
ls1 = [[randint(1, 10) for _ in range(3)] for __ in range(3)]
ls2 = [randint(1, 10) for _ in range(8)]
print(ls1)
print(ls2)
used = []
for _ in ls1:
for i in _:
if i in ls2 and i not in used:
print(i, end=' ')
used.append(i)
Из двумерного массива 3x3
from random import randint
ls1 = [[randint(1, 10) for _ in range(3)] for __ in range(2)]
ls2 = [randint(1, 10) for _ in range(8)]
print(ls1)
print(ls2)
used = []
for _ in ls1:
for i in _:
if i in ls2 and i not in used:
print(i, end=' ')
used.append(i)
(если что я не списывала просто ответ правильный ,а как я то по другому запишу?)