- 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
How can I remove items out of a Python tuple?
Tuples in python are immutable. If you want to remove items out of a Python tuple, you can use index slicing to leave out a particular index. For example,
a = (1, 2, 3, 4, 5) b = a[:2] + a[3:] print(b)
This will give the output:
(1, 2, 4, 5)
Or you can convert it to a list, remove the item and convert back to a tuple. For example,
a = (1, 2, 3, 4, 5) ls_a = list(a) del ls_a[2] b = tuple(ls_a) print(b)
This will give the output:
(1, 2, 4, 5)
- Related Articles
- How can I define duplicate items in a Python tuple?
- How can I subtract tuple of tuples from a tuple in Python?
- How can I append a tuple into another tuple in Python?
- How can I create a Python tuple of Unicode strings?
- How can I do Python Tuple Slicing?
- How can I create a non-literal python tuple?
- How I can convert a Python Tuple into Dictionary?
- How can I convert a Python tuple to string?
- How can I use Multiple-tuple in Python?
- How can I convert Python strings into tuple?
- How can I convert a Python tuple to an Array?
- How I can dump a Python tuple in JSON format?
- How can I convert a Python Named tuple to a dictionary?
- How can I convert Python tuple to C array?
- How can I represent python tuple in JSON format?

Advertisements