Python:Tuples
lastmod 2015-04-05created 2015-04-051 edits
Syntax
Unlike lists, tuples do not let you change element values directly, so you have to cut and paste them as you did with strings.
List and Tuple
You can also easily convert a tuple to a list and a list to a tuple.
p = (1, 2, 3)
q = list(p) # 튜플 p로 리스트 q로...
## q = [1, 2, 3]
r = tuple(q) # 리스트 q로 튜플 r로...
## r = (1, 2, 3)
Swapping two values
Variadic argument tuples
Put * in front of the argument.
The output is as follows.