Luke Paireepinart wrote:
> Scott Oertel wrote:
>> Someone asked me this question the other day, and I couldn't think of
>> any easy way of printing the output besides what I came up with pasted
>> below.
>>
>> So what you have is a file with words in it as such:
>>
>> apple
>> john
>> bean
>> joke
Scott Oertel wrote:
> Someone asked me this question the other day, and I couldn't think of
> any easy way of printing the output besides what I came up with pasted
> below.
>
> So what you have is a file with words in it as such:
>
> apple
> john
> bean
> joke
> ample
> python
> nice
>
> and you w
Alan Gauld wrote:
> "Scott Oertel" <[EMAIL PROTECTED]> wrote
>> Do you have any good documentation that could shed some more light
>> on
>> exactly how to use format strings in such a way?
>
> The docs contain the basic documentation
http://docs.python.org/lib/typesseq-strings.html
> # there's
"Scott Oertel" <[EMAIL PROTECTED]> wrote
>> Use format strings. You can calculate the column widths by
>> analyzing
>> the data then create a format string for the required number of
>> columns.
>> Finally insert the data on each row from a tuple.
>>
> Do you have any good documentation that cou
Scott Oertel wrote:
> #!/usr/bin/env python
>
> data = {}
> lrgColumn = 0
>
> for line in open("test.txt","r").read().splitlines():
> char = line[0].lower()
> if not char in data:
> data[char] = [line]
> else:
> data[char].append(line)
I like
data.setdefault(char,
Alan Gauld wrote:
> "Scott Oertel" <[EMAIL PROTECTED]> wrote
>
>
>> and you want to sort and output the text into columns as such:
>>
>> a p j b n
>> apple python john bean nice
>> ample joke
>>
>> and
"Scott Oertel" <[EMAIL PROTECTED]> wrote
> and you want to sort and output the text into columns as such:
>
> a p j b n
> apple python john bean nice
> ample joke
>
> and this is what works, but I would