[Tutor] Unzipping a list
Monika Jisswel
monjissvel at googlemail.com
Fri Aug 1 13:04:48 CEST 2008
>
> >>> answers= ['ask','tell','repeat','sell']
> >>>
> >>>
> >>> a = '/usr/program/bin -o '+ ' '.join(answers)
> >>> print a
> /usr/program/bin -o ask tell repeat sell
>
2008/7/8 Faheem <faheem at atlantiscomputing.com>:
> Hey all,
>
> If anyone is interested I found this while googling
>
> answers= ['ask'.'tell','repeat','sell']
>
> def unzip(answers):
> unzipped = "".join(answers) # if all items are strings
> unzipped = ", ".join(map(str, answers))
> unzipped = " ".join(str(v) for v in answers if v > 0)
> return unzipped
>
> will give the following
>
> ask tell repeat sell
>
> :)
>
>> hey all,
>> How can i pass the elements of a list in the follwoing manner?
>>
>> L =['ask'.'tell','repeat','sell']
>>
>> To illustrate my question:
>> how can i pass the above list as follows
>>
>> "/some/program/run -o ask tell repeat sell"
>>
>> thanks in advance
> _______________________________________________
> 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/20080801/34a32512/attachment.htm>
More information about the Tutor
mailing list