♧ Computer science 3

[Python] enumerate을 통해 순회하기

[Python] enumerate을 통해 순회하기Geeks가 함수 참고할 때 좋은 듯하다. (간단하게 정리만 하고 자세한 내용은 링크에서 확인할 수 있다).https://www.geeksforgeeks.org/enumerate-in-python/ Enumerate() in Python - GeeksforGeeksA Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.www.geeksfor..

[Python] split() 함수를 사용한 문자열 분할하기.

[Python] split() 함수를 사용한 문자열 분할하기.https://python-reference.readthedocs.io/en/latest/docs/str/split.html(상단의 링크에서 자세히 확인 가능, 하단은 이해한대로 정리한 것).아무런 인자도 주지 않을 경우 split() 함수는 공백(" ")을 기준으로 주어진 문자열(str)을 분할한다.구분 문자와 구분 횟수 인자는 선택적으로 사용할 수 있다.e.g. '-'를 통해 구분하고, 3 번 문자열을 분할하고자 하는 경우 str.split('-'. 3)이 된다.하단의 예는 '-'을 기준으로 3 번 분할하기에 공백 3개와  '-a---b--c-'이 출력된다. 단, 주어진 문자열의 첫 번째와 가장 마지막의 공백은 분할 구분자로 취급하지 않는다.

[Python] append()와 extend(), 리스트에 원소 추가

[Python] append()와 extend()하단의 목차를 클릭하여 이동할 수 있습니다 :)1. append()2. extend()3. 비교 표4. Referenceappend()와 extend() 모두 파이썬 리스트에 원소를 추가할 때 사용한다.1. append()사용하는 방법은 list.append(item)으로 사용한다.item : 추가될 원소주어진 item을 하나의 원소로 리스트에 추가한다. (a = [1, 2, 3]).a.append(1) → a = [1, 2, 3, 1]a.append([1, 2, 3]) → a = [1, 2, 3, [1, 2, 3]]a.append('string') → a = [1, 2, 3, 'string']a.append(['a', 'b', 'c']) → a = [1,..