[Tutor] Raw input query (?)

Steven D'Aprano steve at pearwood.info
Thu Aug 25 15:02:27 CEST 2011


Lisi wrote:
> I copied and ran the following script:
[...]
> What extra should I have done because the variable value came from the 
> keyboard, and why is it different from the first example?

You can investigate this yourself:


 >>> a = 12
 >>> a = raw_input("please type 12")
please type 12 12
 >>> a = 12
 >>> b = raw_input("please type 12: ")
please type 12: 12
 >>> a
12
 >>> b
'12'


See the difference? Here's more of a clue:


 >>> type(a)
<type 'int'>
 >>> type(b)
<type 'str'>



-- 
Steven



More information about the Tutor mailing list