index and find

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shi Mu

    #1

    index and find

    what is the difference between index and find in the module of string?
    for both "find" and "index", I got the position of the letter.

    On 10/19/05, Shi Mu <samrobertsmith @gmail.com> wrote:[color=blue]
    > I have installed Python 2.3 and I type "help()" and then "Keywords".
    > I get a list of words. And it says that I can enter any of the words
    > to get more help. I enter
    > "and" and I get the following error message:
    > "Sorry, topic and keyword documentation is not available because the Python
    > HTML documentation files could not be found. If you have installed them,
    > please set the environment variable PYTHONDOCS to indicate their location.."
    >
    > but I have set both the environment variable, with the path to be
    > C:\Python23\Doc which includes python23.chm
    > Why I still got the above error message?
    >[/color]
  • Sam Pointon

    #2
    Re: index and find

    >>> s = 'foobar'[color=blue][color=green][color=darkred]
    >>> s.find('z')[/color][/color][/color]
    -1[color=blue][color=green][color=darkred]
    >>> s.index('z')[/color][/color][/color]

    Traceback (most recent call last):
    File "<pyshell#3 2>", line 1, in -toplevel-
    s.index('z')
    ValueError: substring not found


    Pretty self explanatory.

    Comment

    Working...