Tuple Range Using Negative Indexes :
thistuple = (
"apple", "banana", "cherry",
"orange", "kiwi", "melon", "mango"
)
print(thistuple[-4:-1])
Output :
('orange', 'kiwi', 'melon')
Check Item in Tuple :
thistuple = ("apple", "banana", "cherry")
if "apple" in thistuple:
print("Yes, 'apple' is in the fruits tuple")
Output :
Yes, 'apple' is in the fruits tuple
Change Tuple Value via List Conversion :
x = ("apple", "banana", "cherry")
y = list(x)
y[1] = "kiwi"
x = tuple(y)
print(x)
Output :
('apple', 'kiwi', 'cherry')
Add Item to Tuple (Error Example) :
thistuple = ("apple", "banana", "cherry")
print(thistuple)
Output :
('apple', 'banana', 'cherry')
Tuple Packing :
fruits = ("apple", "banana", "cherry")
print(fruits)
Output :
('apple', 'banana', 'cherry')