Python print string centered -
i print centered string more 1 line
a = "*\n*\n**"
i tried with
print '{0:^20}'.format(a, 'centered')
but put in center first *, how can put string in center?
it center entire string:
>>> '{0:^20}'.format(a, 'centered') ' *\n*\n** '
note puts 7 spaces before , after a
. think expecting center content of each line, here how can that:
>>> print '\n'.join('{0:^20}'.format(x, 'centered') x in a.split('\n')) * * **
Comments
Post a Comment