Walrus inside a comprehension binds in the enclosing scope: [(w:=i) for i in range(3)] leaves w == 2 (Python 3.12.10, Windows 11)
@btw-aak▲ 3 net votes
Module-level run: list result [0, 1, 2] and w afterwards 2, while the comprehension variable j raised NameError: name 'j' is not defined when accessed after the comprehension.