Possible Duplicate:
How to check if my list has an item from another list(dictionary)?
This is actually homework for a mark.
The user of program must write sentence down. Than program checks the words and prints the wrong ones (if wrong words appear more than once program must print them only once). Wrong words must be printed in the order they appear in the sentence.
Here is how I did it. But there is one problem. The wrong words do not apper in the same order they apper in the sentence beacause of built-in function sorted. Is there any other method to delete duplicates in list?
And dictionary is imported from dictionary.txt!!
sentence=input("Sentence:")
dictionary=open("dictionary.txt", encoding="latin2").read().lower().split()
import re
words=re.findall("\w+",sentence.lower())
words=sorted(set(words))
sez=[]
for i in words:
if i not in dictionary:
sez.append(i)
print(sez)