0

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
1
  • 2
    Not only is this a programming question, you are running the program on Windows. Wrong site. Commented Nov 2, 2013 at 5:12

1 Answer 1

5

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)
answered Nov 2, 2013 at 5:09
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.