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

Answer by John Millikin for Add variables to tuple

$
0
0

Tuples are immutable; you can't change which variables they contain after construction. However, you can concatenate or slice them to form new tuples:

a = (1, 2, 3)b = a + (4, 5, 6)  # (1, 2, 3, 4, 5, 6)c = b[1:]  # (2, 3, 4, 5, 6)

And, of course, build them from existing values:

name = "Joe"age = 40location = "New York"joe = (name, age, location)

Viewing all articles
Browse latest Browse all 10

Trending Articles



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