(Sep-16-2018, 11:51 AM)Windspar Wrote: [ -> ]...
'{0:0>6}\n'
{
0 = first variable
...
That has been redundant in most cases after 2.6 - unless you print a list/tuple and want to use selected elements and/or change the order of elements.
Thanks volcano63,
I also try with a for instruction but now an invalid syntax in line 10,
def add_zero(nbr: str, m: int = 6) -> str:
return "0" * (m - len(nbr)) + nbr
with open("dico2.txt","w") as f:
for a in range(999999):
if a <= 99999:
num_str = add_zero(str(a))
else:
num_str = str(a)
f.write(num_str '\n')
a += 1
Anybody, can this code run just changing syntax in line 10?
You missed the +
I didn't mean just add '\n'
I meant you need to use concatenation:
string + string
In this case one string comes from a variable the other from a literal string, namely '\n'
Ty gruntfutuk, ty all,
It works now.