[Python] for.. not in.. Remove Deduplication
2017-11-21 14:52
323 查看
Write a function,
Suggested test cases: Try an input list with no duplicate elements. The output list should be the same size as the original list. Try a small input list with a known number of unique entries, and some duplicates. Verify that the list without duplicates has the correct length.
remove_duplicatesthat takes a list as its argument and returns a new list containing the unique elements of the original list. The elements in the new list without duplicates can be in any order.
Suggested test cases: Try an input list with no duplicate elements. The output list should be the same size as the original list. Try a small input list with a known number of unique entries, and some duplicates. Verify that the list without duplicates has the correct length.
def remove_duplicates(source): target = [] for element in source: if element not in target: target.append(element) return target
相关文章推荐
- eWave: Leveraging Energy-Awareness for In-line Deduplication Clusters
- Design Tradeoffs for Data Deduplication Performance in Backup Workloads
- appium for python client scroll to view(not in current screen)
- Searching for equivalent of FileNotFoundError in Python 2
- Server.MapPath() error 'ASP 0175 : 80004005' The '..' characters are not allowed in the Path parameter for the MapPath m
- MVN 构建项目时的一个问题--Could not resolve de pendencies for projec
- python练习- for in range()
- python3 TypeError: 'str' does not support the buffer interface in python
- 解决Win10安装PyWin32问题Python Version 3.4 required which was not found in the registry
- How to overcome “datetime.datetime not JSON serializable” in python?
- file - How do I remove/delete a folder that is not empty with Python? - Stack Overflow
- 【转】python version 2.7 required,which was not found in the registry
- Number range for trans./event type WA in year 2011 does not exist
- iOS 推送问题 registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later
- entry for sde instance not found in services file解决方法(转)
- JNI遇到error: request for member 'FindClass' in something not a structure or union
- entry for sde instance not found in services file解决方法
- Python version 2.7 required, which was not found in the registry
- Python写入文件时报错: 'ascii' codec can't decode byte 0xe6 in position 55: ordinal not in range(128)
- python 360 社区 监控 爬虫 in not in 问题