val = 3
tup = ( 'a', 3.14, "zzz" )
I wanted this:
( 3, 'a', 3.14, "zzz" )
not this:
( 3, ( 'a', 3.14, "zzz" ) )
It turns out that this is exactly what the '+' operator does for tuples.
In general, adding two tuples creates a bigger flat tuple from the elements of each.
For this problem the answer then was:
(val,) + tup
Easy. :)
Note:
(val,) results in a tuple with a single element.
2 comments:
Thanks! Been searching for this solution for about 20 minutes, seems these kinds of problems always get me.
You're welcome!
Post a Comment