Input function

Revision as of 22:28, 10 March 2011 by Smitschu (talk | contribs) (Created page with 'In Python, the '''input''' function prompts the user for input. It has the following syntax answer = input([prompt]) When called, it will print <tt>prompt</tt> to the scree…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In Python, the input function prompts the user for input. It has the following syntax

answer = input([prompt])

When called, it will print prompt to the screen, and wait for the user to type something and press enter. Then, the text the user entered is stored as a string in answer.

Because the user input is always stored as a string, to convert it to an integer or floating point number it's necessary to use one of Python's type conversion functions.

See Also

Python 3.2 Documentation