Answers for "how to append elements in tuple"

0

tuple push

a = ('Product', '500.00', '1200.00')
a = list(a)
a.insert(3, 'foobar')
a = tuple(a)
print a

>> ('Product', '500.00', '1200.00', 'foobar')
Posted by: Guest on March-24-2020
0

how to add number in tuple

a = ('2',)
b = 'z'
new = a + (b,)
Posted by: Guest on August-04-2020
0

how to append a tuple to a list

a_list = []
a_list.append((1, 2))       # Succeed! Tuple (1, 2) is appended to a_list
a_list.append(tuple(3, 4))  # Error message: ValueError: expecting Array or iterable
Posted by: Guest on December-02-2020

Browse Popular Code Answers by Language