Skip to content

Instantly share code, notes, and snippets.

@Vigowebs
Created January 4, 2023 20:07
Show Gist options
  • Save Vigowebs/af18d5802120193c067c96f9a9d9cafb to your computer and use it in GitHub Desktop.
Save Vigowebs/af18d5802120193c067c96f9a9d9cafb to your computer and use it in GitHub Desktop.
Walrus operator in python
numbers = [1, 2, 3, 4]
# Without the walrus operator
i = 0
while i < len(numbers):
print(numbers[i])
i += 1
# With the walrus operator
while (i := 0) < len(numbers):
print(numbers[i])
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment