walrus.md

April 17, 2022 ยท View on GitHub

Walrus

Modify the following code so it will use the walrus operator:

x = 50
y = x - 20
if y == 30:
    print("super")

Solution

x = 50
if y := x - 20 == 30:
   print("super")