Question: def read _ file ( file ) : d 1 = { } with open ( file , ' r ' , encoding = 'utf
def readfilefile:
d
with openfilerencoding'utf as infile:
lines infile.readlines
for index in range lenlines:
if linesindexstrip:
continue
cnt intlinesindexstrip
shw linesindex strip
if cnt in dkeys:
shlist dgetcnt
shlist.appendshw
else:
dcntshw
return d
def outkeyd filename:
with openfilenamew as q:
for key in sorteddkeys:
qwrite:
formatkey; joindgetkey
print: formatkey; joindgetkey
def outtitled filename:
ttl
for title in dvalues:
ttlextendtitle
with openfilenamew as outfile:
for title in sortedttl:
outfile.write
formattitle
printtitle
def mainx:
fname x
d readfilefname
if d is None:
printError: Entered file does not exist!: formatfname
return
outfile 'outputkeys.txt
outfile 'outputtitles.txt
outkeyd outfile
outtitled outfile
printEntere input file name:
userinput input
mainuserinput
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
