作业:
答案:
0.[1,2,3,4,5]
1.
>>> list1 = [1,[1,2,['小甲鱼'],3,4,5,8,14,18]]
>>> list1[1][2][0] = '小鱿鱼'
>>> list1
[1, [1, 2, ['小鱿鱼'], 3, 4, 5, 8, 14, 18]]
2. list1.sort()
3. list1.reserve()
4.
>>>old = [1,2,3,4,5]
>>> old.cope()
>>>[1,2,3,4,5]
>>>old.clear()
>>>[]
5. list1 = [(x,y) for x in range(10) for y in range(10) if x%2 ==0 if y%2!= 0]
列表推导式还原出来
list1[]
for x in range(10)
for y in range(10):
if x%2 == 0:
if y%2 != 0:
list1.append((x,y))
6.
>>> list2 = ['4.阿迪达斯','2.李宁','3.鱼c工作室','1.耐克']
>>> list1 = ['1.Just do it', '2.一切皆有可能','3. 让编程改变世界', '4.Impossible is nothing']
>>> list3 = [name + ':' + slogan[2:] for slogan in list1 for name in list2 if slogan[0] == name[0]]
>>> list3
['1.耐克:Just do it', '2.李宁:一切皆有可能', '3.鱼c工作室: 让编程改变世界', '4.阿迪达斯:Impossible is nothing']