python - TypeError: unsupported operand type(s) for +: 'int' and 'str' even after I change the string to an integer -
I am getting an error for my program and I look around the site and now it is understood that I have tried to add a string to an integer error, but when I use the int (variablename)
command, I get an error while trying to add it.
This is my code that I am working on:
value = input ("how many keys in that value is \ n sum:") int (value) SPC () while a == '1': If price.isdigit (): print (value, 'key') spc () yn = input ("Is this correct? \ N (y / n) Answer:") While yn! = 'Y': spc () price = input ("How much is the value in the key \ n sum:") SPC () print (value, 'key') spc () yn = input ("Is this correct? N (y / n) Answer: "SPC () Brake SPC () print (" This is not a valid key amount ") SPC () Price = input (" How much is the value in keys \ n answer: ")
If you are thinking that what is SPC ()
def (spc): print ("")
I get an error after that and there are other parts of the code but none of these errors Does not belong to not so I left him.
Erorr means on this line: value method input Left margin () Input () gives a string and since you can not add + string and anite to the python, it will give you an error. Total = Total + Change the value with: TypeError: +: Unsupported operation type (s) for 'int' and 'str'
total = total + value
total + = int (value)
Comments
Post a Comment