Created
April 8, 2026 15:18
-
-
Save petergi/3bf5cf3570cb8d6ff761e6f69a2fa831 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Why Python Is Great: | |
| # In-place value swapping | |
| # Let's say we want to swap | |
| # the values of a and b... | |
| a = 23 | |
| b = 42 | |
| # The "classic" way to do it | |
| # with a temporary variable: | |
| tmp = a | |
| a = b | |
| b = tmp | |
| # Python also lets us | |
| # use this short-hand: | |
| a, b = b, a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment