[Q] A better way to print?
Eric Gorr
eRrEiMcOgVoErMrE at cox.net
Sat Feb 22 23:54:37 EST 2003
Dan Schmidt <dfan at dfan.org> wrote:
> 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)
hummm.
Got the following error:
Traceback (most recent call last):
File "beatpath.py", line 62, in ?
print '-'.join(W)
TypeError: sequence item 0: expected string, int found
--
== Eric Gorr ========= http://www.ericgorr.net ========= ICQ:9293199 ===
"Therefore the considerations of the intelligent always include both
benefit and harm." - Sun Tzu
== Insults, like violence, are the last refuge of the incompetent... ===
More information about the Python-list
mailing list