파이썬 if-return문 한 번에 하기

2019. 8. 27. 23:05PL/Python

보통 python에서 if-else문과 return을 결합할 때

 

if(int(integer_str_value) > 0):
            return True
        else:
            return False

 

이렇게 하지만, 한 줄에 이를 결합할 수 있다

 

return True if int(integer_str_value) > 0 else False

'PL > Python' 카테고리의 다른 글