I need a python program that starts with the list a=[1] and then changes it to be 2 then 3 … then 5 then adds another element and the list becomes 1,1 then becomes 1,2, etc until it becomes 5,5 and adds another element and becomes 1,1,1 and keeps going until it has 11 elements equal to 5 so it ends with 5,5,5,5,5,5,5,5,5,5,5
I need a python program that starts with the list a=[1] and then changes
Share
Since this seems like a homework question, you’re only going to get an answer that puts you on the right track.
It seems to me, that you want the following behavior:
So it seems like you’re adding elements forward, but then incrementing them backwards.
I’d look up modular arithmetic, to see how you could make a incrementing backwards clear your list back to 1’s.
Once you do that, consider the range of (x mod 4) + 1.