I'm trying to write an if else statement in shorthand. An if else to check a value and increment if it has not reached a value, otherwise minus a set number.
As an if else this works, but trying to do this as a shorthand version and am stuck.
Is the issue you cant use -= or += in this context? Any help to understand would be appreciated.
Have tried day-=7 if day == 7 else day+=1 - but know this is wrong as the var is already referenced on the left.
If else works fine
day = 5
if day == 7:
day-=7
else:
day+=1
Trying to write this in shorthand and I get an error on the right day+=1 as this is clearly incorrect. Looking for some advice on how to increment the day value if day != 7
day = 5
day-=7 if day == 7 else +=1
The +=1 throws an error.
Expect day to be 6