Assignment7.1
My code:
# Use words.txt as the file name
fname = input("Enter file name: ")
try:
fh = open(fname)
except:
print('File cannot be opened:',fname)
quit()
for line in fh:
line = line.upper()
line = line.rstrip()
print(line)
Code from the instructor:
fh = open('words.txt')
for lx in fh:
ly = lx.rstrip()
print(ly.upper())
Reflection:
- be more familiar with: open(),for in :, str.rstrip(), print(str.upper())
- be more concise
- well done and keep going!