On 05/11/12 01:52, Oscar Benjamin wrote:
On 5 November 2012 01:45, Ashley Fowler <afowl...@broncos.uncfsu.edu> wrote:
I'm trying to  initialize a list to several elements using the string
method. I have some idea that you use a for loop I suppose...

It will help if you work on getting your terminology clearer.
Computing is a precise art, it has very specific meanings for things.
From your previous thread I assume you mean that you want break a list down into its individual parts so that you can convert them to strings?

To get the individual parts you do indeed need a loop - a for loop is probably best.

To convert them to strings use the str() type convertor on each
part.

for part in myList:
    myString = str(part)

But assuming this is still part of your previous exercise you really want to create one long string so you probably want the last line to look like

    myString = myString + str(part)

There are more efficient ways of doing that but they might confuse you so I'll leave it with string addition for now.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to