Difference between revisions of "Input function"

(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…')
 
m
 
Line 9: Line 9:
  
 
[[Category:Introduction to Programming]]
 
[[Category:Introduction to Programming]]
 +
[[Category:Python Functions]]

Latest revision as of 15:39, 10 April 2011

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