I have a tuple, and as I know its immutable, is there any indirect way to edit/add elements or remove some?
TUPLE_1 = (1,2,5,3,'kevin','messi')
I want to edit the strings and convert it to a number. And also I want to print the index of the newly added number.
You can convert it to a list and change elements:
TUPLE_1 = (1,2,5,3,'kevin','messi')
LST_1 = list(TUPLE_1)
Now you can change elements. If you need a tuple back:
TUPLE_2 = typle(LST_1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.