1.元素分类 有如下值集合[11,22,33,44,55,66,77,88,99,90], 将所有大于66的值保存至字典的第一个key中,将小于66值保存至第二个key的值中. li = [11,22,33,44,55,66,77,88,99,90] dic = {} n = [] m = [] for i in li: if i > 66: n.append(i) if i < 66: m.append(i) dic.update(k1 = m, k2 = n) print(dic) 2.输
1.列表 # Filename: using_list.py # This is my shopping list shoplist=["apple", "mango", "carrot", "banana"] print ("I have", len(shoplist), "items to purchase.") print ("These items are:"