Last active
August 3, 2019 03:37
-
-
Save mizushou/86c53e5a6a0f8ea44653f2a967fd126a to your computer and use it in GitHub Desktop.
小ネタサンプル
This file contains 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
""" | |
swap with tuple | |
""" | |
x, y = 1, 0 | |
# swap with tuple | |
# tmpなどの変数を使わずにワンラインでswapできる | |
(x, y) = (y, x) | |
# x, yの値がswapしていることがわかる | |
print('x is {}, y is {}'.format(x, y)) | |
# ---> x is 0, y is 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment