#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)

No comments:
Post a Comment