
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Add Tuple to List and Vice Versa in Python
When it is required to add tuple to list and do vice versa, the ‘+’ operator can be used.
Below is the demonstration of the same −
Example
my_list = [3, 6, 9, 45, 66] print("The list is : ") print(my_list) my_tup = (11, 14, 21) print("The tuple is ") print(my_tup) my_list += my_tup print("The list after addition is : " ) print(my_list)
Output
The list is : [3, 6, 9, 45, 66] The tuple is (11, 14, 21) The list after addition is : [3, 6, 9, 45, 66, 11, 14, 21]
Explanation
A list is defined, and is displayed on the console.
A tuple is defined, and is displayed on the console.
The ‘+’ operator is used to add the list and tuple.
This is displayed as output on the console.
Advertisements