列表、元组、字典、集合的定义与操作

l = ['Michael','Bob','Tracy']
l.append('Bob')
l.pop()
print(1)

t = ('Michael','Bob','Tracy')

scores = [85,65,55]

d = {'Michael':85,'Bob':65,'Tracy':55}
d['Bob'] = 82
d['Rose'] = 88
d.pop('Bob')

print(d)

sl = {'Michael','Bob','Tracy'}
s2 = {'Michael',2,3}
sl.add(12)
s2.remove(3)
print(sl,s2)

列表、元组、字典、集合的定义与操作_第1张图片

dl = dict(zip(l,scores))
print(1)
print(scores)
print(dl)

转载于:https://www.cnblogs.com/happybrotherNB/p/9147427.html

你可能感兴趣的:(列表、元组、字典、集合的定义与操作)