Created
June 28, 2012 15:46
-
-
Save epequeno/3012099 to your computer and use it in GitHub Desktop.
raw_input and ints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [13]: a = raw_input("Name ") | |
Name Steven | |
In [14]: a | |
Out[14]: 'Steven' | |
In [15]: type(a) | |
Out[15]: str | |
In [16]: a = raw_input("Number ") | |
Number 23 | |
In [17]: a | |
Out[17]: '23' | |
In [18]: type(a) | |
Out[18]: str | |
In [19]: a = int(a) | |
In [20]: a | |
Out[20]: 23 | |
In [21]: type(a) | |
Out[21]: int | |
In [22]: a = raw_input("Name ") | |
Name steven | |
In [23]: int(a) | |
--------------------------------------------------------------------------- | |
ValueError Traceback (most recent call last) | |
/home/steven/<ipython-input-23-c8db2292b237> in <module>() | |
----> 1 int(a) | |
ValueError: invalid literal for int() with base 10: 'steven' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment