Answer to Question #17918 in Python for Jo Anne Ciminello

Question #17918
Need to convert uniuqe.py to include a main and three functions, buildUnique(), sortUnique() and printUnique() """
File: unique.py
Project 5.7

Prints the unique words in a text file in alphabetical order.
"""

# Take the input file name
inName = input("Enter the input file name: ")

# Open the input file and initialize list of unique words
inputFile = open(inName, 'r')
uniqueWords = []

# Add the unique words in the file to the list
for line in inputFile:
words = line.split()
for word in words:
if not word in uniqueWords:
uniqueWords.append(word)
uniqueWords.sort()

# Prints the unique words
for word in uniqueWords:
print(word)
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS