On 03/03/17 18:52, Peter Otten wrote: > Antonio Zagheni via Tutor wrote: > >> suitcase = ["book, ", "towel, ", "shirt, ", "pants"] > > Hm, looks like you opened Rafael's suitcase while he wasn't looking, and > sneaked in some commas and spaces ;) > > That's cheating...
Its also very difficult to maintain since if you add new items to the suitcase you need to make sure they all have commas except the last one. And inconsistent data formatting in a list is a nightmare. For example, what happens if you decide to sort the list, the last item is no longer last and the commas are all messed up. That's one reason why join() is a better solution, it handles all of that for you. It's also faster, although in a small application you'd never notice the difference. -- 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