[Tutor] Making String
Hugo Arts
hugo.yoshi at gmail.com
Tue Aug 10 22:02:16 CEST 2010
On Tue, Aug 10, 2010 at 2: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".
>
> 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?
>
str.join is the one you want. remember that it's a method of the str
class, and it takes an iterable as an argument. Your list is an
iterable. Try invoking the method on different kinds of strings with
your list as argument, and see if you can figure out how it works.
Maybe start like this:
>>> l = ["3", "2", "5", "1", "0"]
>>> a = "string"
>>> a.join(l)
HTH,
Hugo
More information about the Tutor
mailing list