Copy a file in lowercase

EasyFile Handling Programs · 12 of 38

Write a Python program to copy a file’s contents to another file in lowercase.

Advertisement
Output
hello world
python files

Approach

  1. Read, lower(), write.

Solution

Python
with open("in.txt", "w") as f:    f.write("Hello World\nPYTHON Files\n") with open("in.txt") as src, open("lower.txt", "w") as dst:    dst.write(src.read().lower())print(open("lower.txt").read())
Output
hello world
python files

Learn the concept

New to this topic? Read the lesson, then come back.

More file handling programs

← All 38 File Handling Programs

Leave a Comment