I am writing a cgi script for a web database query "results" page and I need to display the results in an html table. My question: 'Is there a way to print out a list of words without the commas and the square brackets?' e.g if this is the list: is there a way i can get it to print cat, dog, mouse, rat (exactly in the green text format ?

I tried running a loop like this:

for word in list:
            print word,

but that breaks up the columns of the table since each list consist of different numbers of elements. If u have any ideas, i'd be glad to know.

Thanks in advance,


10 Years
Discussion Span
Last Post by Freaky_Chris

I tried ur method what actually happens is the display on pic1. I need it to look like pic2 but without the commas and square brackets. e.g have just canis_familiaris, dog, domestic dog not the whole .

Pic1 is ok, but it breaks up the columns into pieces which is not good enough

Hope my question is clear...

PS. files attached are pic1.jpg and pic2.jpg


Thats ok, I think i figured out a way to solve it!

I use a string function to store each word and then print out the string itself. I'll post it up just in case anyone's interested

line = "" # the string function that stores each word in the list
for word in mlist:
     line = line + word + ", "
print line

Yes indeed that is a good way to solve it. Now i have looked at the pictures i can see what your problem really was. And yes how you have done it is correct

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.