Concatenation of nested tuples
Given two variables
A = (2, 3)
B = (1, 4), (5, 8)
What is the simplest way to combine these two into a result variable C
so that:
C = ((2, 3), (1, 4), (5, 8))
Note that just calling:
C = A + B
leads to:
C = (2, 3, (1, 4), (5, 8))
which is not the desired result.
Also, note that tuples are preferred over lists, so A
, B
and C
can be used elsewhere as dictionary keys.
+3
source to share