89DEVs

Python input() function

overview of input()

The input() function accepts input and returns it. The input is accepted line by line, so multiple input() calls might be necessary to collect all available input.

input() with prompt

If the prompt parameter is used, the string passed is shown as output. # input() function with prompt name = input("Enter your name: ") The output below is shown to the user and the answer is collected and saved as variable name. Enter your name:

input() without prompt

If the prompt parameter is not used, the input() function just collects the input from the user. # input() function without prompt name = input()

syntax of input()

The syntax of the input() function is: input([prompt])

arguments of input()

The input() function has one optional argument, which can be used to write to the standard output. The most common use case of this parameter is to ask a question and then collect the answer.

return values of input()

The input() function returns one line of the input, without any trailing newlines.

                
        

Summary


Click to jump to section