Next / Previous / Contents / TCC Help System / NM Tech homepage

20.34. raw_input(): Prompt and read a string from the user

To prompt for keyboard entry, use this function:

raw_input(p)

The argument p is a prompt string that is written to standard output. Then a line is read from standard input and returned as a string, without its trailing newline character.

>>> party = raw_input('Party affiliation: ')
Party affiliation: Slightly silly.
>>> party
'Slightly silly.'

If the user signals end of input (e.g., with Control-D under Unix), the function raises an EOFError exception.