mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 23:11:09 +00:00
3a275caf01
* fixed remove duplicate * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
16 lines
434 B
Python
16 lines
434 B
Python
def remove_duplicates(sentence: str) -> str:
|
|
"""
|
|
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'
|
|
"""
|
|
return " ".join(sorted(set(sentence.split())))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import doctest
|
|
|
|
doctest.testmod()
|