Answers for "how to append values to tuple"

2

how to append number in tuple

a = (3,)
b = list(a)
b.append("Work!")
a = tuple(b)
print(a)
Posted by: Guest on July-25-2021
0

add values to tuple python

# just add a comma (,) after the value you want to add to the tuple.
my_tuple = (1,2,3,4,5)
my_tuple += 6,
my_tuple += 'hi',
print(my_tuple)

>>> (1, 2, 3, 4, 5, 6, 'hi')
Posted by: Guest on October-19-2021

Browse Popular Code Answers by Language