63 146
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #4694 in Python for Will

Question #4694
How do you create a function that takes all the letters of a text file and writes them in all caps into a new file?
Expert's answer
def up_case(inpFileName, outFileName):
inFile = open(inpFileName,
'r');
outFile = open(outFileName, 'w');
d=ord('A')-ord('a');
for line
in inFile:
nline='';
for i in range(len(line)):
if line[i]>='a' and
line[i]<='z':
nline = nline + chr(ord(line[i])+d);
else:
nline =
nline + line[i];
outFile.write(nline);



## TEST.
# Before
running it create file 'a.txt'
up_case('a.txt', 'b.txt')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions