1 Star 0 Fork 324

napole/Python

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
remove_duplicate.py 434 Bytes
一键复制 编辑 原始数据 按行查看 历史
Du Yuanchao 提交于 2020-09-24 19:14 +08:00 . Fixed remove duplicate (#2470)
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()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/napole/Python.git
git@gitee.com:napole/Python.git
napole
Python
Python
master

搜索帮助