Knowledge Base‎ > ‎Programming‎ > ‎Python‎ > ‎Python Reference‎ > ‎




username = raw_input("Please enter your username: ")


A built in function that allows the user to input information using the keyboard.

Note: all input coming from raw_input is of type string. If you need to use numeric input from the user as some other type you will need to convert it first - see interpreter session below.


variable = raw_input(prompt)


variable - a legal variable name in which to store the input from the user

prompt - the message to give the user when asking for input


 Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) 

[GCC 4.0.1 (Apple Inc. build 5493)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> username = raw_input("what is your username? ")

what is your username? Bart

>>> username


>>> type(username)

<type 'str'>

>>> age = raw_input("what is your age? ")

what is your age? 15

>>> age


>>> type(age)

<type 'str'>

>>> age = int(age)

>>> age


>>> type(age)

<type 'int'>