s.index(x[, i[, j]]) will change the s ?

r rt8396 at gmail.com
Thu Sep 10 06:19:09 CEST 2009

On Sep 9, 11:00 pm, s7v7nislands <s7v7nisla... at gmail.com> wrote:
> hi all:
>     what is the s.index() mean? does the index() change the s?
>     In python2.6 doc (6.6.4. Mutable Sequence Types), Note 4:
> Raises ValueError when x is not found in s. When a negative index is
> passed as the second or third parameter to the index() method, the
> list length is added, as for slice indices. If it is still negative,
> it is truncated to zero, as for slice indices.
> Changed in version 2.3: Previously, index() didn’t have arguments for
> specifying start and stop positions.
> who can give a example?  and why the s.remove() also point to note 4?
> Is the document wrong?

the Python command line is your buddy and the IDLE shell is your BFF.

>>> s = 'abcdefg'
>>> s.index('a')
>>> s.index('b')
>>> s.index('g')
>>> len(s)
>>> s

Python strings are immutable!

try this command
>>> help(str)

def get_enlightened():
  import webbrowser

More information about the Python-list mailing list