- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is tuple unpacking in Python?
Before defining tuple unpacking we need to understand what is tuple.
Tuple : In Python tuples are used to store immutable object.A tuple is a sequence of immutable Python objects. Tuples are sequences, the tuples cannot be changed and tuples use parentheses. it assigns (RHS)right hand side of values into (LHS)Left hand side. In other way it is called unpacking of a tuple of values into a variable. In unpacking of tuple number of variables on LHS should be equal to number of values in given tuple. In packing, we put values into a new tuple while in unpacking we extract those values into a single variable.
tuple = ("Tutorials Point", 132, "Employees") # tuple packing (companyname , Employerscount ,Information) = tuple # tuple unpacking print(companyname) print(Employerscount) print(Information)
Tutorials Point 132 Employees
tuple = ("RRS College of Engg and Technology", 6000, "Engineering") # tuple packing (college, student, graduates) = tuple # tuple unpacking # print college name print(college) # print no of student print(student) # print type of college print(graduates)
RRS College of Engg and Technology 6000 Engineering
- Unpacking a Tuple in Python
- Unpacking tuple of lists in Python
- Packing and Unpacking Arguments in Python?
- What is syntax of tuple declaration in Python?
- What is Tuple ID Propagation?
- Check if variable is tuple in Python
- Test if tuple is distinct in Python
- What is the difference between a python list and a tuple?
- What is the difference between a python tuple and a dictionary?
- Check if element is present in tuple in Python
- Flatten tuple of List to tuple in Python
- Tuple Division in Python
- Tuple multiplication in Python
- Why do you think tuple is an immutable in Python?
- Check if one tuple is subset of other in Python