I have :
a=['ab',200]
cap_init=150
I actually want to update the value of my variable a[1]
under some condition. The program can't run this instruction:
int(a[1])=int(a[1])-self.cap_init
It gives this error :
"SyntaxError: can't assign to function call"
When you perform int(a[1])
, it just shows the integer format of a[1]
. In python int()
is a method to type-cast a numeric value to integer. When you are trying to do int(a[1])=...
you are trying to first calculate the value int(a[1]) - self.capacite_int
and then trying to assign this value to the function call of int()
on the left side. If you want to change the value of a[1]
, you need to reassign it simply like this :
a[1] = int(a[1]) - self.cap_init