Any algorithm to preserve whitespaces?

S

Santosh Kumar

I have a working script which takes argv[1] as an input, deassembles
each line, and then each word. Then after it capitalizes all its word
(upcases the first letter) and then prints it out on the stdout.

That script does the capitalization work fine, but, when it reassemble
the the words, it does it like this:

lines.append(' '.join(words))

The biggest problem is, even when the input file has many spaces, it
strips it down to one.

A file with this line:

This line contains many spaces
becomes:

This Line Contains Many Spaces


The whole script will look clumsy here. I have put it up on GitHub,
here is it: https://github.com/santosh/capitalizr.py/blob/master/capitalizr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,736
Latest member
zacharyharris

Latest Threads

Top