728x90
๋ฐ์ํ
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, 'apple': 1, 'w'..
infinitt.tistory.com
728x90
๋ฐ์ํ