Problem 2.4

Upper Case

Write a program uppercase.py that takes a filename as command-line argument and prints all the contents of the file in uppercase.

$ cat files/five.txt
One
Two
Three
Four
Five

$ python uppercase.py files/five.txt
ONE
TWO
THREE
FOUR
FIVE

Solution

import sys

path = sys.argv[1]
contents = open(path).read()
print(contents.upper())