Python Write Uppercase Copy
read / writePractice

Copy a file in ALL CAPS

Read input.txt, call .upper(), write the result to output.txt.

Picture this: read, transform, write

Bytes in, uppercase text out.

read()text
→
.upper()ABC
→
write()output.txt

In easy words

You do not edit the original file. You create a new file whose contents are the uppercase copy.

Where this is used

Normalizing messy logs before search, and exporting shout-case labels.

Run algorithm

Each step highlights the matching Python line. Program output appears only when a line that prints actually runs.

Ready
input.txt
output.txt
1with open("input.txt") as fin:
2data = fin.read().upper()
3with open("output.txt", "w") as fout:
4fout.write(data)
5print("output.txt written")
Output:

Example Program

1with open("input.txt", "r", encoding="utf-8") as fin:
2data = fin.read().upper()
3with open("output.txt", "w", encoding="utf-8") as fout:
4fout.write(data)
5print("output.txt written")