Mega Code Archive

 
Categories / Python Tutorial / String
 

Use the string format operator ( % ), or put all of the substrings in a list, and using one join() call to put them all together.tx

print '%s %s' % ('Spanish', 'Inquisition') s = ' '.join(('Spanish', 'Inquisition', 'Made Easy')) print s # no need to import string to use string.upper(): print ('%s%s' % (s[:3], s[20])).upper()