Created
August 16, 2015 04:28
-
-
Save KKarthikeya/8e0f645b3fef783180c1 to your computer and use it in GitHub Desktop.
Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() function. 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 …
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
finlist = list() | |
for line in open(raw_input("Enter the file Name:")): | |
words = line.rstrip().split() | |
for arr in words: | |
if arr in finlist: | |
continue | |
else: | |
finlist.append(arr) | |
finlist.sort() | |
print finlist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nicely done. pointed me in the right direction to correct my codes. Thank you