Created
June 11, 2018 20:37
-
-
Save Mohamed2del/b26f60950a9e30c78333ae7b77acab27 to your computer and use it in GitHub Desktop.
#File_processing For each line, split the line into a list of words using the split() method. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, sort and print the resulting words in alphabetical order.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fname = input("Enter file name: ") | |
fh = open(fname) | |
lst = list() | |
for line in fh: | |
word = line.rstrip().split() | |
for element in word: | |
if element in lst: | |
continue | |
else : | |
lst.append(element) | |
lst.sort() | |
print(lst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment