[Tutor] printing items form list

David Rock david at graniteweb.com
Fri Mar 3 14:01:27 EST 2017


> On Mar 3, 2017, at 12:52, Peter Otten <__peter__ at web.de> 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...

yeah, just a little. :-)

You can use join for this:

suitcase = ["book", "towel", "shirt", "pants"]
output = ', '.join(suitcase)
print ("You have a %s in your luggage.") %output


—
David Rock
david at graniteweb.com






More information about the Tutor mailing list