Saturday, October 1, 2011

List manipulation at the command line.


>>> alist = ['one','two','three']
>>> alist
['one', 'two', 'three']
>>> alist.pop[2]
Traceback (most recent call last):
  File "", line 1, in
TypeError: 'builtin_function_or_method' object is not subscriptable
>>> alist
['one', 'two', 'three']
>>> alist.append('four')
>>> alist
['one', 'two', 'three', 'four']
>>> alist.pop([3])
Traceback (most recent call last):
  File "", line 1, in
TypeError: an integer is required
>>> alist.pop(3)
'four'
>>> alist
['one', 'two', 'three']
>>>

Followers

Blog Archive

About Me

My photo
Biking helps me to cope with life.