리스트 내포(List comprehension)
# '1 2 3 4'를 입력받아 [1,2,3,4] 리스트 생성
[int(i) for i in input().split()] # == list(int(i) for i in input().split())
# tuple version
tuple(int(i) for i in input().split())
참고:
https://wikidocs.net/22
https://stackoverflow.com/questions/16940293/why-is-there-no-tuple-comprehension-in-python
'Language > python' 카테고리의 다른 글
[python] random list with no duplicates (0) | 2017.12.08 |
---|---|
[python] selenium install (0) | 2017.11.30 |
[python] pip error: Command "python setup.py egg_info" failed with error code 1 (0) | 2017.11.27 |
[python] ctypes.CFUNCTYPE 사용법 (0) | 2017.11.27 |
[python] converting bytes to ctypes.c_short array (0) | 2017.11.26 |
WRITTEN BY
- hojongs
블로그 옮겼습니다 https://hojongs.github.io/