Python Forum

Full Version: Is this right code for 3 digit pin ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is this the right code for a 3 digit pin ?

for pin in range(1000): if test(f'{pin:03d}'): print(f'{pin:03d}')
Not sure what you want by "right code", but that format will give you the three-digit, zero-prefixed string for any number under 1000.