Objective
In Python every value has a truth value: None, False, zero, empty strings and empty collections are falsy; everything else is truthy. It is used in if without writing comparisons.
Instructions
- Read an integer
nand thennlines, each with a Python literal (for example0,[]or"hello"). - Evaluate each literal with
ast.literal_evaland showliteral: truthyif it is truthy orliteral: falsyif it is falsy.
3
0
[1]
""
0: falsy
[1]: truthy
"": falsy
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise