P
Python
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
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