Horje
append to a tuple Code Example
how to append number in tuple
a = (3,)
b = list(a)
b.append("Work!")
a = tuple(b)
print(a)
append to a tuple
a = ('tree', 'plant', 'bird')
b = ('ocean', 'fish', 'boat')
# a and b are both tuples

c = a + b
# c is a tuple: ('tree', 'plant', 'bird', 'ocean', 'fish', 'boat')
python append to tuple list
apple = ('fruit', 'apple')
banana = ('fruit', 'banana')
dog = ('animal', 'dog')
# Make a list with these tuples
some_list = [apple, banana, dog]
# Check if it's actually a tuple list
print(some_list)
# Make a tuple to add to list
new_thing = ('animal', 'cat')
# Append it to the list
some_list.append(new_thing)
# Print it out to see if it worked
print(some_list)
how to add number in tuple
a = ('2',)
b = 'z'
new = a + (b,)




Python

Related
map function to change type of element in python Code Example map function to change type of element in python Code Example
python function overloading Code Example python function overloading Code Example
how to make a variable in python Code Example how to make a variable in python Code Example
tuple python Code Example tuple python Code Example
backend in python Code Example backend in python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7