This is a sort of beginner question but I couldn’t find a good answer.
I have:
self.date = ( self.date + 1 ) % 31
So the results start at 0 1 2 3 … and ends in 29 30 0 1 ….
How do I shift it such that it starts at 1 2 3 4 and results in 30 31 1 2 3 … with as clean as a syntax as possible?
I think this is what you mean.
EDIT: I saw your comment on the other answer, and here’s an explanation of what you’re doing:
(self.date % 31)means to take the value of date and find the remainder when you divide by 31 (which you know). If you useself.date +1 % 31, then starting withdate = 0you will get 1,2,3..30. Whendate=30, it will end up as30+1 % 31, or31 % 31which is 0.If you add the 1 after, at
date=30you will have30 % 31, still giving you30, then +1 to give the 30,31,1 you want.