The repository contains a collection of different programming snippets to different programming languages from own developments as well as other projects
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/python/Tuple/Python program to add an it...

16 lines
502 B

#create a tuple
tuplex = (4, 6, 2, 8, 3, 1)
#tuples are immutable, so you can not add new elements
#using merge of tuples with the + operator you can add an element and it will create a new tuple
tuplex = tuplex + (9,)
#adding items in a specific index
tuplex = tuplex[:5] + (15, 20, 25) + tuplex[:5]
#converting the tuple to list
listx = list(tuplex)
#use different ways to add items in list
tuplex = tuple(listx)