TypeError: can't multiply sequence to non-int

Python Python at essene.com
Mon Nov 3 21:33:15 CET 2003


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





More information about the Python-list mailing list