I am not getting why the colon shifted left in the second time
>>> print '%5s' %':' : >>> print '%5s' %':' '%2s' %':' : : Help me out of this please
In Python, juxtaposed strings are concatenated:
>>> t = 'a' 'bcd' >>> t 'abcd' So in your second example, it is equivalent to:
>>> print '%5s' % ':%2s' % ':' which by the precedence rules for Python's % operator, is:
>>> print ('%5s' % ':%2s') % ':' or
>>> print ' :%2s' % ':' : :