Code
input_f = input("Enter the file name to read from: ")
output_f = input("Enter the file name to write to... ")
fw = open(output_f, "w")
with open(input_f) as fo:
for w in fo:
for c in w:
if c.isalpha():
fw.write(c.lower())
if c.isspace():
fw.write('\n')
fo.close()
fw.close()
input.txt
HELLO
12345
WORLD
67890
UTRECHT
030
dafsf434ffewr354tfffff44344fsfsd89087uefwerwe
output.txt
hello
world
utrecht
dafsfffewrtffffffsfsduefwerwe
Sources
-
How to convert string to lowercase in Python?
-
http://www.pythonforbeginners.com/files/reading-and-writing-files-in-python
-
How to read a single character at a time from a file in Python?
-
How to check if text is “empty” (spaces, tabs, newlines) in Python?
solved Writing only lower case letters to file in Python