[Q] A better way to print?

Dan Schmidt dfan at dfan.org
Sat Feb 22 18:42:42 EST 2003


eRrEiMcOgVoErMrE at cox.net (Eric Gorr) writes:

| I have some print code that looks like:
|
|   for i in range(N-1):
|     print W[i],
|     sys.stdout.softspace = 0
|     print '-',
|     sys.stdout.softspace = 0
|
|   print W[-1]
|
| and this outputs things of the form:
|
|   1-0-1-0-0-0
|
| is there a better method?

In this case,

    print '-'.join(W)

will do the trick.

Dan

-- 
http://www.dfan.org




More information about the Python-list mailing list