Question: inputFile = input ( Enter the input file name: ) inFile = open ( inputFile ) uniqueWords = [ ] # Iterate through

inputFile = input("Enter the input file name: ")
inFile = open(inputFile)
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.append(currentWord)
# 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:
print(currentWord)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!