raw_input
(in Python2) and input
(the equivalent in Python3) return str
. you need to convert that to int
or float
to use in calculationsPython 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = raw_input('some number: ') some number: 3 >>> x '3' >>> type(x) <type 'str'> >>> int(x) 3 >>> float(x) 3.0