Raw_Input and Input

There are two functions in Python that you can use to read data from the user: raw_input and input.  You can store the results from them into a variable.

Raw_Input

raw_input is used to read text (strings) from the user:
name = raw_input("What is your name? ")
type(name)

>>output
What is your name? spilcm
type 'str'>

Input

input is used to read integers
age = input("What is your age? ")
print "Your age is: ", age
type(age)

>>output
What is your age? 100
Your age is: 100
type 'int'>

 

Leave a Reply

Your email address will not be published. Required fields are marked *