# Ternary expression

**URL:** <https://forum.codewithmosh.com/t/ternary-expression/688>\
**Category:** Python\
**Created:** [November 14, 2020, 4:15am UTC](https://forum.codewithmosh.com/t/ternary-expression/688 "2020-11-14T04:15:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ziegler](https://avatars.discourse-cdn.com/v4/letter/z/858c86/32.png) [@ziegler](https://forum.codewithmosh.com/u/ziegler)\
**Post date:** [November 14, 2020, 4:15am UTC](https://forum.codewithmosh.com/t/ternary-expression/688/1 "2020-11-14T04:15:45Z")

</div>

how to write this expression if theres nested if else blocks?

---

<div class="post-metadata">

**Author:** ![SAM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sam/32/167_2.png) [@SAM](https://forum.codewithmosh.com/u/SAM)\
**Post date:** [November 14, 2020, 8:57am UTC](https://forum.codewithmosh.com/t/ternary-expression/688/2 "2020-11-14T08:57:42Z")

</div>

It’s called _ternary_ because it has _three_ operands: the value for the true case, the condition, and the value for the false case. You should neither nest nor combine these expressions for readability reasons.
