TypeError: can't multiply sequence to non-int

Tim Ronning tim.ronning at start.no
Mon Nov 3 18:26:45 EST 2003


På Mon, 03 Nov 2003 13:33:15 -0700, skrev Python <Python at essene.com>:

> Hello,
>
> I am just learning Python and am going through some examples. I found
> one  very simple example I can't figure out. Here is the script:
>
> # Enter a number to be squared
> x = raw_input("Enter a number: ")
> int(x)
> sq = x*x
> print sq
>
> I am getting the following error:
>
> Enter a number: 5
> Traceback (most recent call last):
> File "db.py", line 6, in ?
> sq = x*x
> TypeError: can't multiply sequence to non-int
>
> Why is the function "int(x)" not changing the input to an integer?
>
> Thanks for the help, Jim
>

Try x = int(raw_input("Enter a number: "))

Regards
Tim R


-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/





More information about the Python-list mailing list