Python input() Function
Python input() function is used to take user input. By default, it returns the user input in form of a string.
- Prompt: A String, representing a default message (usually screen) before the input. However, it is optional to have a prompt message.
Return: input() returns a string object. Even if the inputted value is an integer it converts it into a string.
Example 1: Taking the Name and Age of the user as input and printing it
By Default, input returns a string. So the name and age will be stored as strings.
Example 2: Taking two integers from users and adding them.
In this example, we will be looking at how to take integer input from users. To take integer input we will be using int() along with input()
Similarly, we can use float() to take two float numbers. Let’s see one more example of how to take lists as input
Example 3: Taking Two lists as input and appending them