# 列表元素访问和计数以及成员资格确认


# 通过索引直接访问元素
a = [10, 20, 30, 40, 50, 20, 30, 20, 30]
print(a[2])

# index()获得指定元素在列表中首次出现的索引[start,end]可以指定从什么位置开始搜索
b = [10, 20, 30, 40, 50, 20, 30, 20, 30]
print(b.index(20))

# count()获得指定元素在列表中出现的次数
c = [10, 20, 30, 40, 50, 20, 30, 20, 30]
print(c.count(20))

# len()返回列表长度
d = [10, 20, 30, 40, 50, 20, 30, 20, 30]
print(len(a))

# 成员资格的判断
e = [10, 20, 30, 40, 50, 20, 30, 20, 30]
print(20 in e)
print(100 not in e)




