get just one character

Micah Elliott mde at micah.elliott.name
Thu Nov 17 19:27:38 CET 2005


On Nov 17, Sinan Nalkaya wrote:
> how can i just get 1 character ? i`ve done a search but just found
> getch() for windows, i need same for unix and raw_input has any
> option that is not documented ?

Get all the characters one at a time:

    >>> inp = raw_input('enter a string> ')
    enter a string> this is a string
    >>> for ch in inp: print ch
    ...
    t
    h
    i
    s

    i
    s

    a

    s
    t
    r
    i
    n
    g

Or just get a single character:

    >>> inp[3]
    's'
    >>>   

-- 
_ _     ___
|V|icah |- lliott             <><             mde at micah.elliott.name
" "     """



More information about the Python-list mailing list