$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · hard · #77

What is printed?

print([x for x in range(5) if x % 2][-1])
  1. 3
  2. 4
  3. 1
  4. IndexError
The comprehension keeps the odd numbers [1, 3]; index -1 is the last of them.
Play Problem Solving ▸