- Learn Python by Building Data Science Applications
- Philipp Kats David Katz
- 113字
- 2021-06-24 13:06:00
The input function
A function that is basically the opposite of print, is input. This function takes some sort of question/statement as an argument, prints it, and requires a user to give an answer—this answer will be returned as a result of the function. It does work in Jupyter, but is mostly used in standalone scripts.
Let's have a look at the following example:
>>> name = input('Your name?')
Your name? Guido
>>> name
Guido
As you can see, when we run the input function, it halts the whole computation, waiting for the operator to type in the value; once a value is added, the program resumes.