The raw_input built-in returns a string.  The '[0]' subscript returns
the first character in the user supplied response as strings support
indexing.

[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> mystr = "asdf"
>>> mystr[0]
'a'
>>>

>>> raw_input("Another one, please: ")[0]
Another one, please: ASDF
'A'
>>>

-Jeff

On 7/13/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> what does the statement "choice = raw_input(prompt)[0]" mean? I don't
> know why there is a '[0]' in the statement.
>
> Thank you very much
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to