Answers for "add values to tuple python"

1

add item to tuple python

>>> T1=(10,50,20,9,40,25,60,30,1,56)
>>> L1=list(T1)
>>> L1
[10, 50, 20, 9, 40, 25, 60, 30, 1, 56]
>>> L1.append(100)
>>> T1=tuple(L1)
>>> T1
(10, 50, 20, 9, 40, 25, 60, 30, 1, 56, 100)
Posted by: Guest on January-28-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

Python Answers by Framework

Browse Popular Code Answers by Language