1. 程式人生 > >組合數據類型綜合練習:1.組合數據類型練習

組合數據類型綜合練習:1.組合數據類型練習

列表 類型 練習 綜合練習 charm 組合 better clas true

#字符串
s = ‘Hello‘
for i in s:
    print(i)
  
# 列表
ls = [‘p‘, ‘y‘, ‘Char‘, ‘m‘]
for i in ls:
    print(i)
  
# 元組
tup = tuple(‘tuple‘)
for i in tup:
    print(i)
  
# 字典
names = [‘Help‘, ‘Make‘, ‘Charm‘, ‘Better‘]
score = [98, 89, 78, 80]
dic = dict(zip(names, score))
print(dic)
for i in dic:
    print(i)
print(dic.keys())
  
# 集合
s = set(dic.keys())
print(s)
for i in s:
    print(i)

  

組合數據類型綜合練習:1.組合數據類型練習