

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Program to Edit objects inside tuple
When it is required to edit the objects inside a tuple, simple indexing can be used.
A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, strings, and so on).
Below is a demonstration for the same −
Example
my_tuple = (45, 67, [35, 66, 74], 89, 100) print("The tuple is : ") print(my_tuple) my_tuple[2][1] = 63 print("The tuple after changes is : ") print(my_tuple)
Output
The tuple is : (45, 67, [35, 66, 74], 89, 100) The tuple after changes is : (45, 67, [35, 63, 74], 89, 100)
Explanation
- A tuple of list is defined, and is displayed on the console.
- Since a tuple is immutable, but if the tuple contains a list, it can be varied.
- This is because the list is actually a mutable type.
- This can be done by accessing the index of the elements in the list.
- It is then displayed as output on the console.
- Related Questions & Answers
- How to press ENTER inside an edit box in Selenium?
- Python program to convert Set into Tuple and Tuple into Set
- Python program to count Bidirectional Tuple Pairs
- Group objects inside the nested array JavaScript
- Python program to Flatten Nested List to Tuple List
- How to edit values of an object inside an array in a class - JavaScript?
- Identify the program to edit an ABAP code
- Different objects inside a package in SAP HANA
- MongoDB query to find multiple matchings inside array of objects?
- Python program to Find the size of a Tuple
- Program to find tuple with same product in Python
- Python program to find hash from a given tuple
- How to access Python objects within objects in Python?
- Flatten tuple of List to tuple in Python
- How to Edit, Compile, and Execute a C++ Program?
Advertisements