Start New Discussion within our Software Development Community

Hello! I've run into a slight problem with my script.
As I iterate through a list of strings, I need to print each string, but they all need to print on the same line, so I used this:

for item in myList:
    print item,

The comma puts each item on the same line, but the problem is that it adds a space between the items. Is there any way around this? I cannot use:

out = ""
for item in myList:
    out += item
print out

Depending on the string, the colour in the console gets changed accordingly before printing it, therefore I cannot add them all to one output string and then that print last. Any help is appreciated!

Ah! sys.stdout.write() .... I've seen it before but I had no clue what it really was. Thanks for pointing it out, Aia!

This question has already been answered. Start a new discussion instead.