1
Ich mache ein Programm zum Entfernen doppelter Wörter in einer Liste in Python mit der split()
Funktion.Entfernen von Duplikaten in einer Liste
Meine Antwort ist falsch, da die doppelten Elemente nicht entfernt werden.
romeo.txt:
But soft what light through yonder window breaks
It is the east and Juliet is the sun
Arise fair sun and kill the envious moon
Who is already sick and pale with grief
Mein Code:
fhand=open(romeo.txt)
arr=list()
count=0
for line in fhand:
words=line.split()
if words in arr:
continue
else:
arr=arr+words
arr.sort()
print(arr)