a = [1, 5, 2, 1, 1, 5]
def f(items):
s = set()
for item in items:
if item not in s:
yield item
s.add(item)
print(*f(a))
Задачи по питону и машинному обучению: алгоритмы, функции, классы, регулярные выражения, итераторы, генераторы, ООП, исключения, numpy, pandas, matplotlib, scikit-learn, TensorFlow и др. #Python #ml
a = [1, 5, 2, 1, 1, 5]
def f(items):
s = set()
for item in items:
if item not in s:
yield item
s.add(item)
print(*f(a))