The input file and the desired output
The task is to reformat the following input format.
Computing
“I do not fear computers. I fear lack of them.”
— Isaac Asimov
“A computer once beat me at chess, but it was no match for me at kick boxing.”
— Emo Philips
“Computer Science is no more about computers than astronomy is about telescopes.”
— Edsger W. Dijkstra
To the following output format.
“I do not fear computers. I fear lack of them.” (Isaac Asimov)
“A computer once beat me at chess, but it was no match for me at kick boxing.” (Emo Philips)
“Computer Science is no more about computers than astronomy is about telescopes.” (Edsger W. Dijkstra)
The Python code doing the job
The following simple code could do the reformatting in less than a second for a file that contained multiple hundreds quotes.
file = open("input")
content = file.readlines()
file.close()
lines = []
next_line = ""
for line in content:
line = line.strip()
if len(line) > 0 and len(line.split()) > 1:
if line[0] == '“':
next_line = line
elif line[0] == '—':
next_line += " (" + line[2:] + ")"
lines.append(next_line)
next_line = ""
file = open("output", "w")
for line in lines:
file.write(line + "\n")
file.close()
Python Circle
Do you know what the 5 key success factors every programmer must have?
How is it possible that some people become programmer so fast?
While others struggle for years and still fail.
Not only do they learn python 10 times faster they solve complex problems with ease.
What separates them from the rest?
I identified these 5 success factors that every programmer must have to succeed:
- Collaboration: sharing your work with others and receiving help with any questions or challenges you may have.
- Networking: the ability to connect with the right people and leverage their knowledge, experience, and resources.
- Support: receive feedback on your work and ask questions without feeling intimidated or judged.
- Accountability: stay motivated and accountable to your learning goals by surrounding yourself with others who are also committed to learning Python.
- Feedback from the instructor: receiving feedback and support from an instructor with years of experience in the field.
I know how important these success factors are for growth and progress in mastering Python.
That is why I want to make them available to anyone struggling to learn or who just wants to improve faster.
With the Python Circle community, you can take advantage of 5 key success factors every programmer must have.

Be part of something bigger and join the Python Circle community.