Tuples are immutable, which means we cannot change their values directly. But we can convert a tuple into a list, update it, and then convert it back to a tuple.
Tuple immutable होता है, यानी आप सीधे इसका data change नहीं कर सकते। लेकिन आप tuple को पहले list में बदल सकते हैं, फिर update करके दोबारा tuple बना सकते हैं।
students = ("Abhishek", "Chaitanya", "Naincy")
student_list = list(students)
student_list[1] = "Aryan"
students = tuple(student_list)
print(students)
Output:
("Abhishek", "Aryan", "Naincy")
students = ("Abhishek", "Naincy")
students = students + ("Jayati",)
print(students)
Output:
("Abhishek", "Naincy", "Jayati")
students = ("Abhishek", "Naincy", "Aryan")
student_list = list(students)
student_list.remove("Naincy")
students = tuple(student_list)
print(students)
Output:
("Abhishek", "Aryan")