python判断元素在列表中的索引位置

2022-04-15 00:00:00 索引 元素 判断

python判断元素在列表中的索引位置,使用了list类型的index方法

list = ["red","green","blue"]
assert list.index("red") == 0
assert list.index("blue") == 2

相关文章