Question: inputFile = input ( Enter the input file name: ) inFile = open ( inputFile ) uniqueWords = [ ] # Iterate through
inputFile inputEnter the input file name:
inFile openinputFile
uniqueWords
# Iterate through each line in the file
for line in inFile:
# Split the line into words
words line.split
# Iterate through each word in the line
for currentWord in words:
# Remove punctuation from the word
currentWord currentWord.strip
# Check if the word is not already in the list of unique words
if currentWord not in uniqueWords:
uniqueWords.appendcurrentWord
# Close the file
inFile.close
# Sort the list of unique words
uniqueWords.sort
# Print the sorted list of unique words
print
for currentWord in uniqueWords:
printcurrentWord
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
