li = [11,22,33,44,55,66,77,88,99]分类
方法一:
li = [11,22,33,44,55,66,77,88,99]
s = []
m = []
for i in li:
if i <= 55:
s.append(i)
else:
m.append(i)
print(s)
print(m)
方法二:
li = [11,22,33,44,55,66,77,88,99]
dic = {
'k1':[],
'k2':[]
}
for i in li:
if i <= 55:
dic['k1'].append(i)
else:
dic['k2'].append(i)
print(dic)