Weird Python line of the day:

`>>> [10, 20, 15, 12, 9][_]`
`[20, 15]`

**How can you achieve this?**

_Note: this is not something you'll want to do in real code, just a Python curiosity!_

@s_gruppetta Usually _ contains the last output in a repl. So I guess for you its something like 1:2 and then you are accesing those elements from your list.

@out_of_cheese @s_gruppetta

```
_ = slice(1,3)
```

does the magic. Note, that `_` can be used as a normal variable name.

@erikdesmedt @out_of_cheese Correct, and in the standard Python REPL, the underscore stores the last value, so you don't need to assign it, either

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.