Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 14 - Tuples, Sets, and Dictionaries - Programming Exercises - Page 497: 14.8

Answer

code

Work Step by Step

# 14.8 (Display nonduplicate words in ascending order) Write a program that prompts # the user to enter a text file, reads words from the file, and displays all the nonduplicate # words in ascending order. filename = open(input("Enter text file: ")) lines = filename.readlines() lines = [line.lower() for line in lines] words = set() for line in lines: for word in line.split(): words.add(word) i = 0 for x in words: print(x, end=' ') i += 1 if i == 10: print() i = 0
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.