#modify tuples using slicing
my_tuple = (1,2,3,4,5,6,7)
sliced_tuple = my_tuple[1:4] # indexes 0 to 3
# Changing tuple values
my_tuple = (4, 2, 3, [6, 5])
# TypeError: 'tuple' object does not support item assignment
# my_tuple[1] = 9
# However, item of mutable element can be changed
my_tuple[3][0] = 9 # Output: (4, 2, 3, [9, 5])
print(my_tuple)
# Tuples can be reassigned
my_tuple = ('p', 'r', 'o', 'g', 'r', 'a', 'm', 'i', 'z')
# Output: ('p', 'r', 'o', 'g', 'r', 'a', 'm', 'i', 'z')
print(my_tuple)
# Change Value In Tuple :-
friends = ("Mido", "Lucifer", "Abdelrhman")
# Example => Wanna Change ( Abdelrhman ) To ( Aiiob );
# First We Need Transformation From Tuple To List ,
# We Need To Create Variable With Any Name
# After This We Use list() Function
oneName = list(friends)
# After This We Need Change The Value ,
oneName[-1] = "Aiiob"
# After This We Need Transformation From List To Tuple ,
# We Use tuple() Function
friends = tuple(oneName)
# And We Done (: