Hi! I am currently looking for some freelance projects. If you have a project idea in mind please feel free to send me an email or check out my personal website. If you want to get to know about my journey, you can read this article: How I got into programming

This works simply because True == 1 and False == 0, and so can be done
with lists in addition to tuples.

The above example is not widely used and is generally disliked by
Pythonistas for not being Pythonic. It is also easy to confuse where to
put the true value and where to put the false value in the tuple.

Another reason to avoid using a tupled ternery is that it results in
both elements of the tuple being evaluated, whereas the if-else
ternary operator does not.

Example:

condition=Trueprint(2ifconditionelse1/0)#Output is 2print((1/0,2)[condition])#ZeroDivisionError is raised

This happens because with the tupled ternary technique, the tuple is
first built, then an index is found. For the if-else ternary operator,
it follows the normal if-else logic tree. Thus, if one case could
raise an exception based on the condition, or if either case is a
computation-heavy method, using tuples is best avoided.