Newbie Question: Can't multiply sequence by non-int of type 'str'

Paulo Repreza pxrepreza at gmail.com
Sat Jan 31 19:42:42 EST 2009


Hi,

Thanks for your reply. It worked.

Paulo Repreza

On Sat, Jan 31, 2009 at 4:25 PM, Robert Kern <robert.kern at gmail.com> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090131/5c18991e/attachment-0001.html>


More information about the Python-list mailing list