Python - Use boolean value to pick up value in list

Introduction

The bool function is converted into the equivalent of integer 1 or 0.

You can use them as offsets to pick true and false values from a list:

A = [Z, Y][bool(X)] 
For example: 

Demo

print( ['f', 't'][bool('')] )
print( ['f', 't'][bool('test')] )

Result

Related Topic