LPTHW Exercise 7: More Printing

Learn Python the Hard Way by Zed Shaw .: I am practising printing in Python 2 using the print() and format() functions inherited from Python 3:

>>> poem = 'The Wreck of the Hesperus'
>>> poet = 'Longfellow'
>>> print(poem + " by " + poet)
The Wreck of the Hesperus by Longfellow
>>> print("{}" + " by " + poet).format(poem)
The Wreck of the Hesperus by Longfellow
>>> print("{}" + " by " + "{}").format(poem, poet)
The Wreck of the Hesperus by Longfellow
>>>

More • pythonprogramming