I would to print centered a string that is more than 1 line
a = "*\n*\n**"
I tried with
print '{0:^20}'.format(a, 'centered')
but it put in the center just the first *, how can i put all the string in center?
I would to print centered a string that is more than 1 line
a = "*\n*\n**"
I tried with
print '{0:^20}'.format(a, 'centered')
but it put in the center just the first *, how can i put all the string in center?
Copyright © 2021 Jogjafile Inc.
It actually does center the entire string:
Note that this puts seven spaces before and after
a
. I think you are expecting it to center the content of each line, here is how you can do that: