On 02/06/15 15:15, Peter Otten wrote:

Not an optimization, but if the user enters neither Y nor N you might ask
again instead of assuming Y.

He does. He only breaks if the user enters N

         choice = input('Do you want to play again y/n: ')
         if choice.upper() == 'N':
             print('end of game')
             break
         elif choice.upper() != 'Y':
             print("invalid choice")

Y goes round again silently.
Anything other than Y or N prints the error then tries again.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to