Python input() Function – Taking User Input

Any Software System or program written in any programming language at the end would be used by some user. So there need to be some way to send data inside a software system. For this Python uses built-in function input(), which asks user to enter some data( like string, number).
So input() function would put a hold on execution of program until something is entered by user. Once user enter something Python Program would take it in and further execute the program.
Quite Simple. Below are some examples showing use of input() function in a Python Program.

Example 1

some_input = input()
#Asking user for some input, without showing any message

Example 2

some_input = input("Enter some name: ")
#Putting some string inside input() function would prompt user the message first and
#then wait for user to enter the value

Do note that whatever is entered by user will be treated as string by Python. So enter 18 will be a string, but if specifically you want to treat this as a number internally in the program. Then you have to use type casting functions like int()

Example 3

some_input = int(input())
# type of some_input variable will be interger not string

Read More About Python

Leave a Comment