Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a43ac9b

Browse files
TusharShandilyatrekhleb
authored andcommitted
Update test_tuples.py (trekhleb#6)
* Update test_tuples.py * Update test_tuples.py Fixed code style issues. (Trailing whitespace, blank line whitespace and line length too long) * Update test_tuples.py * Update test_tuples.py * Update test_tuples.py * Update test_tuples.py * pep8 compliant
1 parent aa7ffef commit a43ac9b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

‎src/data_types/test_tuples.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_tuples():
6161
# pylint: disable=trailing-comma-tuple
6262
singleton_tuple = 'hello', # <-- note trailing comma
6363
assert len(singleton_tuple) == 1
64-
assert singleton_tuple == ('hello', )
64+
assert singleton_tuple == ('hello',)
6565

6666
# The following example is called tuple packing:
6767
packed_tuple = 12345, 54321, 'hello!'
@@ -76,3 +76,10 @@ def test_tuples():
7676
# right-hand side. Sequence unpacking requires that there are as many variables on the left
7777
# side of the equals sign as there are elements in the sequence. Note that multiple assignment
7878
# is really just a combination of tuple packing and sequence unpacking.
79+
80+
# Swapping using tuples.
81+
first_number = 123
82+
second_number = 456
83+
first_number, second_number = second_number, first_number
84+
# Data can be swapped from one variable to another in python using
85+
# tuples. This eliminates the need to use a 'temp' variable.

0 commit comments

Comments
 (0)