Spring Deals - hours only!Up to 70% off on all courses and bundles.-Close
5. Extended integer placeholders
Date and time
Padding and Alignment


Great! Now, let's try to extend the {:d} placeholder. Take a look:

user_id = 287360
print('Your ID is {:08d}.'.format(user_id))

Result: Your ID is 00287360.

The {:d} placeholder means "print the integer value as it is." The extended {:08d} placeholder means "reserve at least eight characters for the integer value and fill any empty characters with zeroes."


Suppose we have picture files named 1.jpg, 2.jpg, 3.jpg, ..., 30.jpg.

We would like those file names to have up to three leading zeroes so that they are sorted correctly even when more files are added: 0001.jpg, 0002.jpg, 0003.jpg, etc.

Your task is to generate and print such file names from 0001.jpg until 0030.jpg. Put each file name on a new line.

Stuck? Here's a hint!

Use a for loop:

for i in range (1, 31):