반응형 [python3.11 상세] 데이터구조 데이터 구조List- 초기화: list() 메서드- 인덱스: list[idx]- 슬라이싱: list[start:end:step]- 삽입: list.insert(index, data)- 추가: list.append(data)- 확장: list.extend(data)- 삭제: del list[idx]; list.pop(idx)- 처음 값 삭제: list.remove(data)- 오름차순 정렬: sort(reverse=False)- 뒤집기: list.reverse()- 데이터 탐색: list.index(data)- 데이터 개수: list.count(data) Dictionary- 초기화: dict() 메서드- 인덱스: dict["key"]; dict.get("key", None)- 추가: dict.update.. 2024. 7. 3. [python3.10 기본] 6. 데이터 구조 6.1 리스트 (List)리스트는 순서가 있는 변경 가능한 데이터 구조로, 다양한 타입의 요소를 포함할 수 있습니다. 리스트 생성fruits = ["apple", "banana", "cherry"]리스트 요소 접근print(fruits[0]) # appleprint(fruits[1]) # bananaprint(fruits[-1]) # cherry리스트 요소 변경fruits[1] = "blueberry"print(fruits) # ["apple", "blueberry", "cherry"]리스트 요소 추가fruits.append("date")print(fruits) # ["apple", "blueberry", "cherry", "date"]리스트 요소 삭제fruits.remove("blueberry.. 2024. 7. 1. 이전 1 다음 반응형