list

Published onesixx on

T/F

Python

특정 문자열을 포함한 원소 찾기

https://lapina.tistory.com/108

list comprehension 이 핵

Python

List 합집합, 교집합, 차집합, 대칭차

https://zetawiki.com/wiki/Python_리스트 합집합, 교집합, 차집합, 대칭차

Python

리스트에 리스트를 리스트로 (2차원 리스트를 1차원 리스트로 변환, flatten)

https://codechacha.com/ko/python-flatten-list/

sum(iterable, [])은 []에 iterable의 모든데이터를 더하는 함수.
[] + ['2'] + ['25'] + ['78']의 연산을 수행하면서 결국 2차원에서 1차원 리스트로 변환

itertools.chain()는 인자로 전달되는 *arg
*arg는 *LL 이렇게 써도 되고, 몇개의 인수를 받을 지 모르지만, 받아서 처리하고, Tuple형태로 출력

Python

알파벳 예제 만들기

Python

list 나누기

Python

값 삽입

append() : 마지막에 데이터 v 추가

myList.append(‘v’)

Python

insert() : i인덱스에 v추가

myList.insert(2, ‘v’)

Python

list 합치기,확장 extend()

aList + bList

aList.extend(bList)

Python

삭제

리스트.remove(a) 리스트에 있는 a 원소찾아 삭제

del 리스트[i] i인덱스에 있는 원소 삭제

리스트.pop(i) 리스트에 있는 i인덱스 꺼내서 Return하면서 버림

정렬 list.sort() vs. sorted(list)

<list>.sort() <list>.reverse()

None을 반환

원본 리스트 순서를 변화시킨다. (새로운 복사본을 만들지 않기 때문에 빠름)

sorted(<list>)

정렬된 새로운 리스트를 반환

찾기

‘a’ in myList : T/F 를 return

문자열 변경

Python

스트링.startswirh(“ss”) & 스트링.endswith(“.txt”)

Python
Python

Categories: Python Basic

onesixx

Blog Owner

guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x