Answers for "how to append elements to tuple python"

2

appending items to a tuple python

tuple_item = ("Grepper")
#print(tuple_item)
converted = list(tuple_item)
#print(type(converted))
converted.append(" is amazing")
convert_to_tur = tuple(converted)
print(convert_to_tur)
Posted by: Guest on July-26-2021
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

Python Answers by Framework

Browse Popular Code Answers by Language