立即学习:https://edu.csdn.net/course/play/26676/338786?utm_source=blogtoedu
a='123'
b='abc'
z=zip(a,b)
list(z)
>>[(1,'a'),(2,'b'),(3,'c')]
enumerate()#枚举
s=['one','two','three','four']
list(enumerate(s))
>>[(0,'one'),(1,'two'),(2.'three'),(3,'four')]
列表解析
lst=[]
for i in range(10):
lst.append(i**2)
lst
>>[0,1,4,9,16,25,36,49,64,81]
例题2:字符串s='life if short you need python'.统计这个字符串每个单词的字母数量。