mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 23:11:09 +00:00
Refactor remove duplicates to more pythonic (#2093)
* Refactor strings/remove_duplicate to more pythonic * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
parent
bf0da25e4f
commit
3de6f010c3
|
@ -258,6 +258,10 @@
|
||||||
* [Scc Kosaraju](https://github.com/TheAlgorithms/Python/blob/master/graphs/scc_kosaraju.py)
|
* [Scc Kosaraju](https://github.com/TheAlgorithms/Python/blob/master/graphs/scc_kosaraju.py)
|
||||||
* [Tarjans Scc](https://github.com/TheAlgorithms/Python/blob/master/graphs/tarjans_scc.py)
|
* [Tarjans Scc](https://github.com/TheAlgorithms/Python/blob/master/graphs/tarjans_scc.py)
|
||||||
|
|
||||||
|
## Greedy Method
|
||||||
|
* [Greedy Knapsack](https://github.com/TheAlgorithms/Python/blob/master/greedy_method/greedy_knapsack.py)
|
||||||
|
* [Test Knapsack](https://github.com/TheAlgorithms/Python/blob/master/greedy_method/test_knapsack.py)
|
||||||
|
|
||||||
## Hashes
|
## Hashes
|
||||||
* [Chaos Machine](https://github.com/TheAlgorithms/Python/blob/master/hashes/chaos_machine.py)
|
* [Chaos Machine](https://github.com/TheAlgorithms/Python/blob/master/hashes/chaos_machine.py)
|
||||||
* [Enigma Machine](https://github.com/TheAlgorithms/Python/blob/master/hashes/enigma_machine.py)
|
* [Enigma Machine](https://github.com/TheAlgorithms/Python/blob/master/hashes/enigma_machine.py)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Created by sarathkaul on 14/11/19
|
""" Created by sarathkaul on 14/11/19 """
|
||||||
|
|
||||||
|
|
||||||
def remove_duplicates(sentence: str) -> str:
|
def remove_duplicates(sentence: str) -> str:
|
||||||
|
@ -7,13 +7,7 @@ def remove_duplicates(sentence: str) -> str:
|
||||||
>>> 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'
|
||||||
"""
|
"""
|
||||||
sen_list = sentence.split(" ")
|
return " ".join(sorted(set(sentence.split(" "))))
|
||||||
check = set()
|
|
||||||
|
|
||||||
for a_word in sen_list:
|
|
||||||
check.add(a_word)
|
|
||||||
|
|
||||||
return " ".join(sorted(check))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user