Python input() built-in function

From the Python 3 documentation

If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, EOFError is raised.

Introduction

The input() function in Python is a built-in function that allows a program to read a line of text from the user’s keyboard. It is an essential tool for creating interactive applications, as it pauses the program’s execution and waits for the user to provide input. The function can also display a prompt to guide the user on what to enter.

Examples

This function takes the input from the user and converts it into a string:

# ask for their name
print('What is your name?')
my_name = input()
print('Hi, {}'.format(my_name))
What is your name?
Martha
Hi, Martha

input() can also set a default message without using print():

# default message
my_name = input('What is your name? ')
print('Hi, {}'.format(my_name))
What is your name? Martha
Hi, Martha