list
list.reverse()
list.sort()
list.index(obj):obj is the object to be find out; it returns index of the found object otherwise raise an exception indicating that value does not find.
aList = [123, ‘xyz‘, ‘zara‘, ‘abc‘]; print "Index for xyz : ", aList.index( ‘xyz‘ ) ; //return 1 print "Index for zara : ", aList.index( ‘zara‘ ) ;//return 2
list.append(x)
list.insert(i, x):insert x after list[i].
list.pop():the last item will be removed.
list.pop(3) :delete the list[3].the argument is index.so sometimes, you may use list.pop(list.index(obj))
list.remove(sth):delete the ‘sth‘.
list.extend(an_iter):add each item from the iterable an_iter onto the list.
Difference between extend and append:
iteration
warning: we can‘t modify a list while interating over it.
settle: create another list
时间: 2024-10-12 04:17:15