Konvertering av tuple til liste i Python
For å lage en liste fra en tuple, må du
bruke funksjonen list:
pythontpl = ('a', 'b', 'c')
res = list(tpl)
print(res) # vil skrive ut ['a', 'b', 'c']
Задание 1
Gitt en tuple:
pythontpl = ('2', '6', '12')
Lag en liste av den.
Задание 2
Gitt tupler:
pythontpl1 = ('1', '2', '3')
tpl2 = ('4', '5')
Lag følgende liste fra dem:
python['1', '2', '3', '4', '5']
Задание 3
Gitt en tuple:
pythontpl = (1, 2, 3, 4, 5)
Snudd den:
python(5, 4, 3, 2, 1)