Skip to content

Commit e5dfba3

Browse files
✨ std_lib: variable swapping
1 parent a6fd8e4 commit e5dfba3

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

standard_lib/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,5 @@ A collection of useful snippets using only the standard library.
7171
| unicode_source_code | Example on how awesome unicode in source code is |
7272
| update_dict_using_tuples | Update a dict using a list of tuples representing key-value-pairs |
7373
| uuid1_example | Generate RFC compliant UUID |
74+
| variable_swapping | Swap the values of two variables in one line of code |
7475
| zip_safe | Illustrates how zip is stopping if one iterable is exhausted without a warning and how to prevent it |

standard_lib/variable_swapping.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
x = 4
2+
y = 5
3+
x, y = y, x
4+
print(x)
5+
print(y)

0 commit comments

Comments
 (0)