How to Adding and changing items in a Tuple-Modify nested items of a tuple:

 #how to Adding and changing items in a Tuple

tup = (0, 1, 2, 3, 4, 5)

slist = list(tup)

slist.append(6)

tup = tuple(slist) # converting list back into a tuple

print(tup)  


#Modify nested items of a tuple:

tup = (10, 20, [25, 75, 85])

print(tup)

tup[2][0] = 250

print(tup)

how to Adding and changing items in a Tuple


No comments:

Post a Comment

Latest Post

How to Generate Barcode and QR code For Our Products

 మీ products కి barcode / QR code generate చేయాలంటే OPTION 1: ONLINE (No Coding – Quick) Best for small shops / beginners 👉Free websites: T...