Issue
I currently started using python 3 from python 2. In Python 2 the strings typecasting could be done easily using int()
function but I am having problem in Py3.5.3
current = input("Enter the Current price: ")
int(current)
print (type(current))
c = current - 24
current is still shown as Class str
even after the typecast function.
Error is TypeError: unsupported operand type(s) for -: 'str' and 'int'
I know this is a just a small error but the examples I have looked up on net are all using the int function like I used. What could be the problem here
Solution
You're not saving the return value from int(current)
, which is the integer representation. Try
current = int(current)
That should do it.
Answered By - csl
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.