[Tutor] need help reading the code

Alan Gauld alan.gauld at btinternet.com
Mon Jul 7 21:49:34 CEST 2014


On 07/07/14 19:29, keith papa wrote:

Please post in plain text and avoid attachments if possible.
Just paste code directly into the email.

I've had to cut n paste everything to write this which is a pain...

 >>> print '{0} was {1} years old when he wrote this book'.format(name, age)

 >>> print 'Why is {0} playing with that python?'.format(name)

# I no that the code will give you the same output even without numbers:

Yes the numbers are not needed here but consider this example:

 >>> print "{0} loves {1} but {2} hates {0}!".format('Joe', 'food', 'Anne')

Now you need the numbers because you are using the same value (0)twice.

I'll look at the other issues in separate mails.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list