newbie question concerning formatted output
Dave Hansen
iddw at hotmail.com
Tue Nov 29 13:22:02 EST 2005
On Tue, 29 Nov 2005 17:40:08 GMT in comp.lang.python, Thomas Liesner
<t.liesner at creativ-consulting.de> wrote:
[...]>
>So instead of:
>
>3905
>3009
>0000
[...]
>
>i'd like to have:
>
>3905 3009 0000
[...]
>
>This is the codesnippet i am using:
>
>#!/usr/bin/python
>
>import string
>inp = open("xyplan.nobreaks","r")
>data = inp.read()
>for words in data.split():
> print words
>inp.close()
>
>Any hints?
Here's an obvious, if naive, implementation:
data = imp.read().split()
for i in range(0,len(data),3):
tl = data[i:i+3]
for d in tl:
print d,
print
inp.close()
HTH,
-=Dave
--
Change is inevitable, progress is not.
More information about the Python-list
mailing list