Pretvorba nabora v seznam v Pythonu
Če želite iz nabora narediti seznam, morate
uporabiti funkcijo list:
pythontpl = ('a', 'b', 'c')
res = list(tpl)
print(res) # izpiše ['a', 'b', 'c']
Задание 1
Podan je nabor:
pythontpl = ('2', '6', '12')
Naredite iz njega seznam.
Задание 2
Podani so nabori:
pythontpl1 = ('1', '2', '3')
tpl2 = ('4', '5')
Naredite iz njih naslednji seznam:
python['1', '2', '3', '4', '5']
Задание 3
Podan je nabor:
pythontpl = (1, 2, 3, 4, 5)
Obrnite ga:
python(5, 4, 3, 2, 1)