On 2009-01-31 18:19, Paulo Repreza wrote:
Hi,
I'm just learning the very basics of python and I ran into this problem
in version 3.0/3000:
 >>>x = input("x: ")
x: 36
 >>> y = input("y: ")
y: 42
 >>> print (x*y)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
print (x*y)
TypeError: can't multiply sequence by non-int of type 'str'
But when I run the same code with Python 2.6.1 it does prints the result.

In Python 3.0, the 2.x input() function, which evaluates the string, was removed, and the 2.x raw_input() function, which just returns the string that was entered, was renamed to input().

Is there any special function that I should add in order to work
properly under Python 3.0?

x = int(input('x: '))
y = int(input('y: '))

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to