[Tutor] Why is this write defined as a tuple,
instead of picking list?
Adam
adam at monkeez.org
Fri Apr 16 06:16:34 EDT 2004
I'm using this function to cycle through a list and add some
formatting to it to prepare it for saving:
def prepare_for_saving(article_items):
"""This function formats the article_items list
so that it's in HTML format and looks nice"""
print "article_items is type: ", type(article_items)
for x in article_items:
write = "<h3>", article_items[0], "</h3>"
print "write is type: ", type(write)
#write = str(article_items)#deprecated - replaced by the
formatting loop return (write)
At the time article_items is passed it is a list - however,
when I try to do the formatting with write =, write is
declared as a tuple - why is this, and how can I force it to
be a string (I believe I need a string for the file saving
function?)
Thanks
adam
More information about the Tutor
mailing list