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?
1
Expert's answer
2012-04-10T07:34:06-0400
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')
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment