Everyone, hello!
I'm not able to count properly, and I'm at a loss. A second pair of eyes would really be helpful.
I'm getting a variable from my config file as:
import ConfigParser
config = ConfigParser.ConfigParser()
config.read("config.ini")
count1 = config.get('Counter','count1')
>>> print count1
5
However, when I want to simply substract - 1 from this variable, as so:
count1 = (count1 - 1)
I'm confronted with an error:
TypeError: unsupported operand type(s) for -: 'str' and 'int'
Any help would be really appreciated. Thanks!
strand anint, as the error message tells you. Since1is anint, thencount1must be astr. You canprint type(count1)before the line that gives you the error to make sure of that. Then, just convert it withint().