code for Computer Language Shootout
Bryan
belred at gmail.com
Fri Mar 18 09:49:17 EST 2005
> import sys
> import string
>
> def show(seq, table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy',
> 'TGVHCDM\nKNSYAAWBRTGVHCDMKNSYAAWBR')):
> seq = seq.translate(table)[::-1]
> for i in range(0, len(seq), 60):
> print seq[i:i+60]
>
couldn't you change the above for loop to:
print wraptext.fill(seq, 60)
bryan
> def main():
> seq = []
> for line in sys.stdin:
> if line[0] in ';>':
> show(''.join(seq))
> print line,
> del seq[:]
> else:
> seq.append(line[:-1])
> show(''.join(seq))
>
> main()
>
More information about the Python-list
mailing list