11.成员资格:检查特定的值是否包含在序列中,可使用运算符in.
>>> presson='hello ,world!'
>>> 'w' in presson
True
>>> 'j' in presson
False
>>> users=['mlh','foot','feet']
>>> 'mlh' in users
True
12.长度、最小值和最大值
>>> num=[100,35,78,90]
>>> len(num)
4
>>> min(num)
35
>>> max(num)
100
>>> min(2,3,4,5)
2
>>> max(6,7,8,9)
9
13.函数list:
>>> list('hello')
['h', 'e', 'l', 'l', 'o']
14.修改列表:给元素赋值
>>> num=[3,4,5]
>>> num[1]=7
>>> num
[3, 7, 5]
15.列表删除元素
>>> test=['first','second','third','fouth']
>>> del test[1]
>>> test
['first', 'third', 'fouth']
pop()删除元素(内部元素是按栈的方式存储的)
>>> num=[1,2,3,4,5]
>>> num.pop()
5
>>> num
[1, 2, 3, 4]
remove()移除列表中的元素:
>>> num=[1,2,3,4,5]
>>> num.remove(5)
>>> num
[1, 2, 3, 4]