-
-
Save thcipriani/bc1f7fe1f16f4522677a to your computer and use it in GitHub Desktop.
Python For Informatics Ex.8.4
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
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