Sep-16-2018, 01:23 PM
(This post was last modified: Sep-16-2018, 01:23 PM by gruntfutuk.)
(Sep-16-2018, 11:51 AM)Windspar Wrote:with open("dico.txt","w") as f: for a in range(999999): f.write('{0:0>6}\n'.format(a))
'{0:0>6}\n'
{
0 = first variable
:0 = fill
> = left adjust
6 = six spaces
}
left adjust not needed for zero padding
with open("dico.txt","w") as f: for a in range(999999): f.write('{0:06}\n'.format(a))
I'd intended to leave it to the OP to figure out how to do the padding without the function they originally coded.
Not sure the OP wants the \n between numbers either.
That said, why not f-strings rather than format?
I am trying to help you, really, even if it doesn't always seem that way