Omskakeling van tupel na lys in Python
Om 'n tupel na 'n lys te omskep, moet jy
die funksie list gebruik:
tpl = ('a', 'b', 'c')
res = list(tpl)
print(res) # sal ['a', 'b', 'c'] uitvoer
Gegee 'n tupel:
tpl = ('2', '6', '12')
Skep 'n lys daaruit.
Gegee tupels:
tpl1 = ('1', '2', '3')
tpl2 = ('4', '5')
Skep die volgende lys daaruit:
['1', '2', '3', '4', '5']
Gegee 'n tupel:
tpl = (1, 2, 3, 4, 5)
Draai dit om:
(5, 4, 3, 2, 1)