A tuple is a collection which is ordered and unchangeable
tuple = ("apple", "banana", "cherry", "orange", "kiwi", "melon", "mango")
print(thistuple)
print(thistuple[1]) =>"banana"
print(thistuple[-1]) =>"mango"
print(thistuple[2:5]) =>"cherry ... kiwi"
print(thistuple[-4:-1]) =>('orange', 'kiwi', 'melon')
---------------------convert-------------------
x = ("apple", "banana", "cherry")
y = list(x)
y[1] = "kiwi"
x = tuple(y)
---------------------loop------------------
thistuple = ("apple", "banana", "cherry")
for x in thistuple:
print(x)
---------------------test------------------
thistuple = ("apple", "banana", "cherry")
if "apple" in thistuple:
print("Yes, 'apple' is in the fruits tuple")
----------------------len----------------------
thistuple = ("apple", "banana", "cherry")
print(len(thistuple))
----------------------del---------------------
thistuple = ("apple", "banana", "cherry")
del thistuple
----------------------jointuples--------------
tuple1 = ("a", "b" , "c")
tuple2 = (1, 2, 3)
tuple3 = tuple1 + tuple2
-----------------------------------------------------
thistuple = (1, 3, 7, 8, 7, 5, 4, 6, 8, 5)
x = thistuple.count(5) =>nb of repetiton of 5
x = thistuple.index(8)=>3 is the first location of 8
|