What does input() function do in python?



The function input() presents a prompt to the user (the optional arg of raw_input([arg])), gets input from the user. In Python 2.x, it returns the data input by the user in a format that is interpreted by python. For example, if the user inputs "Hello", it is stored as string while if a user enters 5, it is interpreted as an int. In Python 3.x, it returns the data input by the user in string format.

For example

name = raw_input("What is your name? ")
print "Hello, %s." % name

Advertisements