삼항 연산자(Ternary operators)

이상해씨·2023년 11월 16일

삼항 연산자(Ternary operators)

  • 조건문의 if, eles 결과 (True, False일 경우)를 한줄에 표현
  • 문법
True if(<true 조건문>) else False
  • 예시
num= 11
even_num = True if (num % 2 ==0) else False
print(even_num)
#print 결과  : False

참고

profile
공부에는 끝이 없다

0개의 댓글