Skip to content

Instantly share code, notes, and snippets.

@thcipriani
Created May 31, 2011 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thcipriani/bc1f7fe1f16f4522677a to your computer and use it in GitHub Desktop.
Save thcipriani/bc1f7fe1f16f4522677a to your computer and use it in GitHub Desktop.
Python For Informatics Ex.8.4
try:
fhand = open('romeo.txt')
word = []
for line in fhand:
words = line.split()
for chkWords in words:
# if chkWords in word: //The 'standard way' of doing this
# word.remove(chkWords) //would be to replace these
# word = word + words //lines with:
if chkWords in word:
continue
else:
word.append(chkWords)
word.sort()
print word
except:
print "unable to open file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment