[Tutor] Using 'join ' function to create a string
christopher.henk at allisontransmission.com
christopher.henk at allisontransmission.com
Fri Dec 21 17:53:18 CET 2007
this works for me.
Z=", ".join(["%s:%s" %(a,Y[b]) for b,a in enumerate(X)])
lechtlr <lechtlr at yahoo.com>
Sent by: tutor-bounces at python.org
12/21/2007 11:00 AM
To
tutor at python.org
cc
Subject
[Tutor] Using 'join ' function to create a string
Hi there,
I would like to know what is the best way to create a string object from
two different lists using 'join' function. For example, I have X = ['a',
'b', 'c', 'd', 'e'] and Y = [1, 2, 3, 4, 5]. From X and Y, I want to
create a string Z = 'a:1, b:2, c:3, d:4, e:5'.
Any help would greatly be appreciated.
-Lex
Looking for last minute shopping deals? Find them fast with Yahoo!
Search._______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071221/fafef961/attachment.htm
More information about the Tutor
mailing list