Skip to content

Instantly share code, notes, and snippets.

@KKarthikeya
Created August 16, 2015 04:28
Show Gist options
  • Save KKarthikeya/8e0f645b3fef783180c1 to your computer and use it in GitHub Desktop.
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 …
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
@azihcchidi
Copy link

Nicely done. pointed me in the right direction to correct my codes. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment