How can I fix this error:
Traceback (most recent call last):
File "C:\Users\Tony\Desktop\Python4円.py", line 64, in
print "YOU PAY: $",(pc-total)
TypeError: unsupported operand type(s) for -: 'str' and 'float'
asked Nov 2, 2013 at 4:43
Tony
-
2Not only is this a programming question, you are running the program on Windows. Wrong site.jordanm– jordanm2013年11月02日 05:12:01 +00:00Commented Nov 2, 2013 at 5:12
1 Answer 1
One of the two, pc or total, is a float and the other a string.
As python is strongly typed you would need to cast the string to a float, e.g.:
print "YOU PAY $",(float(pc) - total)
Sign up to request clarification or add additional context in comments.
Comments
lang-py