Advertisement
Guest User

Untitled

a guest
Oct 5th, 2022
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | Help | 0 0
  1. def f(*a):
  2.     a=list(a)
  3.     h=set()
  4.     while len(h)<10 and a:
  5.         x=a.pop(0)
  6.         if isinstance(x,list):
  7.             a=x+a
  8.             continue
  9.         elif hasattr(x,'__hash__') and x.__hash__:
  10.             h.add(x)
  11.         else:
  12.             raise Exception(f"Нехешируемый объект [{x}]")
  13.     print(h)
  14.  
  15. f(1,2,4)
  16. f([101,102,[103,104,[105,106],[107,107]],[[[[109]],[[110],[111]]]],7,8,5,4,2,4,3425,242342],2,3,4)
  17. f(1,[2]*1231,5,[2,2,[3],2])
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement