coding utf-8 data def flat data res if data if isinstance data list re

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# -*- coding: utf-8 -*-
data = [1,2,[3,4,[5,6]]]
def flat(data):
res = []
if data != []
if isinstance(data[0],list):
res += flat(data[0])
else:
res.append(data[0])
flat(data[1:])
return res
print flat(data)