string='the tree turn green and green' words=string.split() wordsCount={} for word in words: wordsCount[word]=wordsCount.get(word,0)+1 for wordsCounted in wordsCount.keys(): if wordsCount[wordsCounted]==1: print(wordsCounted)
def _pick_words(s: str): from collections import Counter words = s.split() result = Counter(words) return [w for w, t in result.items() if t == 1]
def _pick_words(s: str): result = {} words = s.split() for word in words: times = result.get(word, 0) result[word] = times + 1 return [w for w, t in result.items() if t == 1]