split print print from itertools import chain import collections def m

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
a = "a*b******c*n*j"
r = a.split("*")
print(a)
print(r)
"""
from itertools import chain
import collections
def merge2(lst2):
return list(chain(*lst2))
def merge3(lst, res=[]):
for el in lst:
merge(el) if isinstance(el, list) else res.append(el)
return res
def merge(lst):
result = []
for s in lst:
if isinstance(s, list):
result.extend(s)
else:
result.append(s)
return result
def merge4(l):
for el in l:
if isinstance(el, collections.Iterable) and not isinstance(el, (str, bytes)):
yield from merge4(el)
else:
yield el
a = [1,2,3,[4,5]]
b = [4]
c = []
d = [1,2,3]
print(a)
print(b)
print(c)
print(d)
r = list(merge4([a,b,c,d]))
print(r)