본문 바로가기
Programming/python

간결한 python 문법을 쓰자 - lambda

by 단창 2022. 5. 9.

python 스러운 코드를 짜자 

ex. 
flatten = lambda l: [item for sublist in l for item in sublist]

#을 풀어서 쓰면 

def flatten(l:list):
	a = []
    for i in l:
    	for j in i:
        	a.append(j)
    return a

 

반응형

'Programming > python' 카테고리의 다른 글

python SSLerror  (0) 2023.10.27
간결한 python 문법을 쓰자 - one line condition  (0) 2022.04.12
[vscode] 외부 모듈을 debug하고 싶을때  (0) 2021.11.23
[python] dataframe 의 column 순서변경  (0) 2020.02.13
python 주석  (0) 2020.01.17