I was padding an output in a print statement with a simple code which uses .format() function
print('{:-<100}'.format('xyz'))
I was able to get a similar output using f-strings by creating a new variable
library = 'xyz'
print(f'{library:-<100}')
Question: Is there a way to add the string 'xyz' inside the f-string without having to create a new variable?
I tried the code below, but it gave me an error:
print(f'xyz:-<100')
print(f"{'xyz':-<100}")print('xyz'.ljust(100, '-')). (It's actually faster than the corresponding f-string.) (Not that I'd care much either way, but it nips the "f-strings are faster" argument against it.)