Difference between revisions of "Input function"

m
 
Line 10: Line 10:
 
[[Category:Introduction to Programming]]
 
[[Category:Introduction to Programming]]
 
[[Category:Python Functions]]
 
[[Category:Python Functions]]
 +
[[Category:Computer programming]]

Latest revision as of 16:11, 18 May 2025

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