Quantcast
Channel: Add variables to tuple - Stack Overflow
Viewing all articles
Browse latest Browse all 10

Answer by Daniel for Add variables to tuple

$
0
0

You can start with a blank tuple with something like t = (). You can add with +, but you have to add another tuple. If you want to add a single element, make it a singleton: t = t + (element,). You can add a tuple of multiple elements with or without that trailing comma.

>>> t = ()>>> t = t + (1,)>>> t(1,)>>> t = t + (2,)>>> t(1, 2)>>> t = t + (3, 4, 5)>>> t(1, 2, 3, 4, 5)>>> t = t + (6, 7, 8,)>>> t(1, 2, 3, 4, 5, 6, 7, 8)

Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>