- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Updating Tuples in Python
Tuples are immutable which means you cannot update or change the values of tuple elements. You are able to take portions of existing tuples to create new tuples as the following example demonstrates −
Example
#!/usr/bin/python tup1 = (12, 34.56); tup2 = ('abc', 'xyz'); # Following action is not valid for tuples # tup1[0] = 100; # So let's create a new tuple as follows tup3 = tup1 + tup2; print tup3;
Output
When the above code is executed, it produces the following result −
(12, 34.56, 'abc', 'xyz')
- Related Articles
- Updating Strings in Python
- Updating Lists in Python
- Updating Dictionary in Python
- Combining tuples in list of tuples in Python
- Count tuples occurrence in list of tuples in Python
- Compare tuples in Python
- How to Concatenate tuples to nested tuples in Python
- Remove duplicate tuples from list of tuples in Python
- How to split Python tuples into sub-tuples?
- Basic Tuples Operations in Python
- Addition of tuples in Python
- Remove matching tuples in Python
- Pairwise Addition in Tuples in Python
- Addition in Nested Tuples in Python
- Python – Ordered tuples extraction

Advertisements