MCPcopy
hub / github.com/TheAlgorithms/Python / remove_duplicates

Function remove_duplicates

strings/remove_duplicate.py:1–9  ·  view source on GitHub ↗

Remove duplicates from sentence >>> remove_duplicates("Python is great and Java is also great") 'Java Python also and great is' >>> remove_duplicates("Python is great and Java is also great") 'Java Python also and great is'

(sentence: str)

Source from the content-addressed store, hash-verified

1def remove_duplicates(sentence: str) -> str:
2 """
3 Remove duplicates from sentence
4 >>> remove_duplicates("Python is great and Java is also great")
5 'Java Python also and great is'
6 >>> remove_duplicates("Python is great and Java is also great")
7 'Java Python also and great is'
8 """
9 return " ".join(sorted(set(sentence.split())))
10
11
12if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected