Konverzia tuple na zoznam v Pythone
Ak chcete z tuple urobiť zoznam, musíte
použiť funkciu list:
tpl = ('a', 'b', 'c')
res = list(tpl)
print(res) # vypíše ['a', 'b', 'c']
Daný tuple:
tpl = ('2', '6', '12')
Vytvorte z neho zoznam.
Dané tuple:
tpl1 = ('1', '2', '3')
tpl2 = ('4', '5')
Vytvorte z nich nasledujúci zoznam:
['1', '2', '3', '4', '5']
Daný tuple:
tpl = (1, 2, 3, 4, 5)
Otočte ho:
(5, 4, 3, 2, 1)