jeapedu 133 集合的習題6

11人阅读 评论(1) 收藏 举报
分类:

链接: https://pan.baidu.com/s/1KZNLIIY_Ag5R2aJxgEueBg 密码: udnp

# 7 delete elements of list b in list a
a = [1, 3, 3, 5, 1, 6]
b = [1, 3, 7, 9]
print(a)
print(b)
for x in a:
    if x in b:
        a.remove(x)
print('left', a)
print(b)
print('----')
a = [1, 3, 3, 5, 1, 6]
b = [1, 3, 7, 9]
print(a)
print(b)
i = 0
while i < len(a):
    if a[i] in b:
        a.remove(a[i])
        i -= 1
    i += 1
print('left', a)
print(b)    
print('----')
a = [1, 3, 3, 5, 1, 6]
b = [1, 3, 7, 9]
print('a', a)
print('b', b)
sa = set(a)
print(sa)
sb = set(b)
print(sb)
ab = sa.intersection(sb)
print('ab', ab)
lab = list(ab)
print('lab', lab)
for x in lab:
    c = a.count(x)
    for y in range(0, c):
        a.remove(x)
print(a)
查看评论

jeapedu 127 集合的習題1

链接: https://pan.baidu.com/s/13xwfMjtKxEK6m8OP27tE8A 密码: v9ea # 1 all the list elements in other lis...
  • cragwen
  • cragwen
  • 2018-04-15 16:13:36
  • 11

jeapedu 128 集合的習題2

链接: https://pan.baidu.com/s/1G4E90F62WV_8DTdwoN0_1Q 密码: vc5w # 2 find common key in two dict d1 = d...
  • cragwen
  • cragwen
  • 2018-04-15 16:14:47
  • 9

jeapedu 132 集合的習題5

链接: https://pan.baidu.com/s/1SzWqGtyiMUH1lsnrQIiHgg 密码: cwx6 # 6 find same value's key d1 = dict(a ...
  • cragwen
  • cragwen
  • 2018-04-15 16:51:22
  • 10

jeapedu 130 集合的習題4

链接: https://pan.baidu.com/s/1egip4ulMGaCKuLzCAbjKlA 密码: si74 # 5 combine two lists, duplicate li1 =...
  • cragwen
  • cragwen
  • 2018-04-15 16:35:31
  • 9

jeapedu 129 集合的習題3

链接: https://pan.baidu.com/s/1eI0ybsXKhU3Zrow8u9fCPA 密码: sv26 # 3 find different item in two tuple t...
  • cragwen
  • cragwen
  • 2018-04-15 16:32:02
  • 11

jeapedu 53&54 split習題

链接: https://pan.baidu.com/s/1i7iteiL 密码: ce2c 链接: https://pan.baidu.com/s/1jJScbrC 密码: 668t s = ''...
  • cragwen
  • cragwen
  • 2018-03-03 20:17:18
  • 14

jeapedu 134 集合的習題6方法二

链接: https://pan.baidu.com/s/14rofE56nqdADYSVaoIv32Q 密码: 9e2s # 7 delete elements of list b in list ...
  • cragwen
  • cragwen
  • 2018-04-15 17:00:11
  • 10

jeapedu 114 複習習題04

链接: https://pan.baidu.com/s/1MIwIvTUqnkw7LZFSI4OKdw 密码: j4su # 4 實現整型列表的排序 # 插入排序,默認開頭是有序的,後面每個值依次插...
  • cragwen
  • cragwen
  • 2018-03-23 21:50:47
  • 13

jeapedu 115 複習習題05

链接: https://pan.baidu.com/s/1THnZ05ryE4Ogje2rt0HbeQ 密码: d6hs print(help(dict)) #形參 def add(x, y): ...
  • cragwen
  • cragwen
  • 2018-03-23 21:51:58
  • 12

jeapedu 113 複習習題03

链接: https://pan.baidu.com/s/1SSFAxa78zG0CzL2Wy7LhMg 密码: nhxu # 3 合併兩列表,去重, insert / append # 4 實現整型...
  • cragwen
  • cragwen
  • 2018-03-23 21:49:22
  • 14
    个人资料
    持之以恒
    等级:
    访问量: 2122
    积分: 1339
    排名: 3万+
    文章分类
    文章存档