Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 파이썬
- TIL #todayilearn #math #javascript #js #자바스크립트 #절댓값 #최댓값 #랜덤 #random #floor
- listdir
- 프리워커스
- HTML
- 프로그래밍폰트
- LIST
- 코딩
- Coding
- 위코드
- Python
- dumpdata
- 역사
- 싸피
- vscode설치
- comprehension
- VSCode
- 티스토리챌린지
- 오블완
- loaddata
- dangerouslySetInnerHTML
- 파라미터
- SSAFY
- phython
- wecode
- CSS
- html #css #코딩 #입문 #코딩시작하기 #코딩입문 #파이썬 #자바스크립트 #비전공자 #비전공 #코딩학원
- Web
- django
- CSS #HTML #코드
Archives
- Today
- Total
당신의 친절한 이웃, 코딩맨
#9 Python - list comprehension 본문
반응형
표현 방법들
[표현식 for 변수 in 반복(순회) 가능한 객체]
ex)
numbers = [1, 2, 3, 4, 5]
[i * 2 for i in numbers]
#[2, 4, 6, 8, 10]
[i for i in numbers if i % 2 ==0]
#[2, 4]
Well.. I really don't use those expressions that much tho; uhm.......maybe for the time will come.
for i in range(len(numbers)):
numbers[i] = int(numbers[i]) * 2
print(numbers)
#[2, 4, 6, 8, 10]
However, the list comprehension help your code shorter.
'Today I Learn (TIL)' 카테고리의 다른 글
#11 CSS position, inline, inline-block, block float (0) | 2020.06.22 |
---|---|
#10 Git - staging area, repository, add, git status, commit, tracked, un tracked, staged, modified, unmodified (0) | 2020.06.10 |
#8 Python - 문자열을 리스트로, 리스트를 문자열로 (0) | 2020.05.27 |
#7 Python - 리스트가 갖고 있는 기능(index, extend, insert, sort, reverse, pop, append, del) (0) | 2020.05.27 |
#6 Python - 문자열 출력 3가지 포맷팅 방법, 소숫점 출력 방법 (0) | 2020.05.26 |
Comments