I want to go through each number in the range 1-1000, but I need my program to be 3 digits. So 001, 002, 003,...,999. How can I do this?
Asked
Active
Viewed 854 times
1
-
Don't confuse data and its representation. – Klaus D. Oct 03 '17 at 22:24
1 Answers
0
You can format it to a string with leading zeroes:
for i in range(0, 1000):
print "%03d" % (i)

Mureinik
- 297,002
- 52
- 306
- 350
-
1And if you prefer using the new-style formatting: `'{:03}'.format(i)`. And if using f-strings it would be: `f'{i:03}'`. – Christian Dean Oct 03 '17 at 22:17