[Tutor] Making String

Joel Goldstick joel.goldstick at gmail.com
Tue Aug 10 22:09:28 CEST 2010


On Tue, Aug 10, 2010 at 3:49 PM, Corey Richardson <kb1pkl at aim.com> wrote:

> Hello, tutors.
>
> I'm attempting to make a string from the items of a list.
> For example, if the list is ["3", "2", "5", "1", "0"], I desire the string
> "32510".
>
> a = ["3", "2", "5", "1", "0"]
my_string = "".join(a)

Or, this even works:

 "".join(["3", "2", "5", "1", "0"])


> I've looked into str.join(), but I can't figure it out. Can someone either
> point me in a different direction, or explain how join() works?
>

The str part of str.join() is the string where the result is stored, so you
can start off with an empty string: ""
The join argument is listed as an iterable, whis is what your list is.


>
> Thank you,
> ~Corey Richardson
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100810/f2f0cd7a/attachment.html>


More information about the Tutor mailing list