Okay so I'm taking a introduction Python course and I have to take a text file with a few sentences and export it to another text file using the command prompt. I've got it basically done but I need help with it exporting to another text file. Any help?
import sys
import string
def main(argv):
args=argv[1:]
settings={}
for entry in args:
e=entry.split(":")
settings[e[0]]=e[1]
count={}
inputfile=open(settings['in'],'r',)
exclude=string.punctuation+"\n"
for lin in inputfile:
chunks=line.split(" ")
for ch in exclude:
chunk=chunk.replace(ch,' ')
if chunk:
if not(chunk in count):
count [chunk]=1
else:
count[chunk]=count[chunk]+1
inputfile.close()
Keys=[key for key in count]
keys=sorted(Keys)
outpufile=open (settings['out'],"w")
for key in Keys:
outputfile.write(key+" "+"/n")