What's the easiest way to generate a string of spaces of length N in Python?
(besides something like this, which is multiline and presumably inefficient for large n:
def spaces(n):
s = ''
for i in range(n):
s += ' '
return s
)
You could do it as a function:
def spaces(n):
return ' ' * n
Or just use the expression:
' ' * n
try this, simple, only one line:
' ' * n
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With