Python列表的index,count,len方法

list1 = ['Tom','Jerry','Chris']

# index 查找元素位置  找不到报错
print(list1.index('Tom'))
# print(list1.index('gfx'))

# count 计数
print(list1.count('Tom'))
print(list1.count('gfx'))

# len 计算长度
print(len(list1))

posted @ 2021-03-08 15:41  code-G  阅读(339)  评论(0编辑  收藏  举报