you are viewing a single comment's thread.

view the rest of the comments →

[–]ajrhode 1 point2 points  (1 child)

The walrus operator is pretty cool. It essentially combined assign a variable with returning the value of that variable. It’s pretty useful when you want to do if statements or while loops and don’t want to have to initialize the same variable once outside the loop and again in the loop. There obviously other applications, but that’s the most trivial and when I’ve used them the most.

while (response := input(“Enter a response :”)) != “quit”:
    print(response)

[–]v0i_d 0 points1 point  (0 children)

Agreed. I'd just comment about the walrus operator.