Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

update tupple in python

#Convert the tuple into a list to be able to change it:
  
x = ("apple", "banana", "cherry")
y = list(x)
y[1] = "kiwi"
x = tuple(y)

print(x)

#Convert into a list
#Convert the tuple into a list, add "orange", 
#and convert it back into a tuple:

thistuple = ("apple", "banana", "cherry")
y = list(thistuple)
y.append("orange")
thistuple = tuple(y)


#Add tuple to a tuple.
#Create a new tuple with the value "orange", and add that tuple:
  
thistuple = ("apple", "banana", "cherry")
y = ("orange",)
thistuple += y

print(thistuple)
 
PREVIOUS NEXT
Tagged: #update #tupple #python
ADD COMMENT
Topic
Name
2+1 =