I wonder, how can I increment a string representing a binary number, all the way up to another binary number? (for use in a while loop, for example).
For example I start with "0000" and after 15 incs, I should reach "1111" (in other words: "0000", "0001", "0010", ..., "1111"). At first this problem seemed really simple, but the only solutions I could come up with were quite ridiculous (not pythonic, some might say). Does anyone have an advice?
Thanks in advance!
[format(n, '04b') for n in range(16)]