[Python] 파이썬을 파이썬답게 - iterable/sequence type 다루기
https://programmers.co.kr/learn/courses/4008 파이썬을 파이썬답게 본 강의는 파이썬 문법을 이미 알고 있는 분들을 대상으로 만들어졌습니다. ##### 이런 분들께 추천합니다 * 파이썬 문법을 알고 계시는 분 * 알고리즘 문제를 조금 더 쉽게 풀고 싶은 분 * Python 코 programmers.co.kr iterable 자신의 멤버를 하나씩 리턴할 수 있는 객체 (반복가능한 객체) list, str, tuple, dictionary 등 [2차원 리스트 행-열 바꾸기] mylist = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] new_list = [[], [], []] for i in range(len(mylist)): for j in range(len..
2022. 1. 15.
[PG/Python] 합승 택시 요금
📌 문제 https://programmers.co.kr/learn/courses/30/lessons/72413 코딩테스트 연습 - 합승 택시 요금 6 4 6 2 [[4, 1, 10], [3, 5, 24], [5, 6, 2], [3, 1, 41], [5, 1, 24], [4, 6, 50], [2, 4, 66], [2, 3, 22], [1, 6, 25]] 82 7 3 4 1 [[5, 7, 9], [4, 6, 4], [3, 6, 1], [3, 2, 3], [2, 1, 6]] 14 6 4 5 6 [[2,6,6], [6,3,7], [4,6,7], [6,5,11], [2,5,12], [5,3,20], [2,4 programmers.co.kr 📌 문제 접근 방법 다익스트라 알고리즘을 사용하여 풀이하였다. 가장 중점이..
2022. 1. 14.
[Python] 세트, 딕셔너리 관련 함수
세트(set) mutable, unorderd, iterable [값 추가] .add(x) : x를 세트에 추가 a = {'사과', '바나나', '수박'} a.add('포도') print(a) # {'포도', '바나나', '사과', '수박'} .update(iterable) : 여러 값을 추가 a = {'사과', '바나나', '수박'} a.update({'토마토', '토마토', '딸기'}, {'포도', '레몬'}) print(a) # {'포도', '토마토', '사과', '레몬', '수박', '딸기', '바나나'} [값 삭제] .remove(x) : x를 삭제하고, 없으면 KeyError 발생 a = {'사과', '바나나', '수박'} a.remove('사과') print(a) # {'바나나', '수박'}..
2022. 1. 10.
[Python] 리스트 관련 함수
리스트 mutable, ordered, iterable [값 추가] cafe = ['starbucks', 'tomntoms', 'hollys'] .append(x) : 리스트에 값 추가, 가장 마지막에 추가됨 cafe.append('banapresso') # ['starbucks', 'tomntoms', 'hollys', 'banapresso'] .extend(iterable) : 리스트에 iterable 값을 붙임 cafe.extend(['wcafe', '빽다방']) # ['starbucks', 'tomntoms', 'hollys', 'wcafe', '빽다방'] cafe.extend('ediya') # ['starbucks', 'tomntoms', 'hollys', 'e', 'd', 'i', 'y', ..
2022. 1. 10.