11
Question Question 1(k)
Find the output generated by following code fragments :
tuple = ( 'a' , 'b', 'c' , 'd' , 'e')
tuple = ( 'A', ) + tuple[1: ]
print(tuple)Output
('A', 'b', 'c', 'd', 'e')
Explanation
tuple[1:] creates a tuple slice of elements from index 1 (indexes always start from zero) to the last element i.e. ('b', 'c', 'd', 'e').+ operator concatenates tuple ( 'A', ) and tuple slice tuple[1: ] to form a new tuple.