Write a Python program to remove an item from a tuple


The program defines a tuple a containing 8 integer elements. The print() function is used to output the original tuple a. Next, the list() function is used to convert the tuple a into a list. The result is assigned to the variable b. The remove() method is then used to remove the value 56 from the list b.

Finally, the list b is converted back into a tuple using the tuple() function, and the result is assigned back to the variable a. The updated tuple a is then printed to the console, as well as its data type (tuple) using the print() and type() functions.

As a result, the output will show the original tuple a, the updated tuple a after removing the value 56, and its data type (tuple). The conversion from tuple to list and back to tuple, as well as the removal of an element from the list, is demonstrated in the program.

Source Code

a = (23,45,56,68,10,45,7,9)
print("Original A :",a)
b = list(a)
b.remove(56)
a = tuple(b)
print("After Removing A :",a)
print(type(t))
 

Output

Original A : (23, 45, 56, 68, 10, 45, 7, 9)
After Removing A : (23, 45, 68, 10, 45, 7, 9)


Example Programs