mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Fixed remove duplicate (#2470)
* fixed remove duplicate * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
parent
902fe1c907
commit
3a275caf01
|
@ -1,14 +1,15 @@
|
||||||
""" Created by sarathkaul on 14/11/19 """
|
|
||||||
|
|
||||||
|
|
||||||
def remove_duplicates(sentence: str) -> str:
|
def remove_duplicates(sentence: str) -> str:
|
||||||
"""
|
"""
|
||||||
Reomove duplicates from sentence
|
Remove duplicates from sentence
|
||||||
>>> remove_duplicates("Python is great and Java is also great")
|
>>> remove_duplicates("Python is great and Java is also great")
|
||||||
'Java Python also and great is'
|
'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(" "))))
|
return " ".join(sorted(set(sentence.split())))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(remove_duplicates("INPUT_SENTENCE"))
|
import doctest
|
||||||
|
|
||||||
|
doctest.testmod()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user