파이썬 - 두 개 이상 중복된 리스트 요소 출력(count)
lis = ['a', 'b', 'c', 'd', 'd'] for (index, value) in enumerate(lis): if lis.count( lis[index] ) >= 2: print(index, value) 참고: https://infinitt.tistory.com/78 파이썬(python) 리스트 중복 요소 개수 찾기 (카운팅) or 제거,삭제하기 (try , except , count) *중복요소 카운팅하기 *try, except 문 사용 count={} lists = ["a","a","b",'apple','w','wf'] for i in lists: try: count[i] += 1 except: count[i]=1 print(count) 결과값 : {'a': 2, 'b': 1, 'ap..
2022. 8. 31.