728x90

 

 

def solution(n):
    return (int(n ** 0.5) + 1) ** 2 if n == int(n ** 0.5) ** 2 else -1

삼항 연산자를 이용하면 한줄로 적을 수 있다.

728x90

+ Recent posts