Python 코딩테스트 끄적끄적
지속적인 업데이트 예정입니다. 1. defaultdict 사용(유사딕셔너리) from collections import defaultdict sample=defaultdict(int) sample['dog'] print(sample.items()) sample['dog']+=1 print(sample.items()) 2. list, dictionary comprehension sample=[x for x in range(10)] print(sample) sample1={x:[] for x in ['a','b','c']} print(sample1) ''' [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] {'a': [], 'b': [], 'c': []} ''' 3. zip : iterable한 객체 ..
2021. 4. 20.