- 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
Adding 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.
- Related Articles
- Python – Test String in Character List and vice-versa
- Binary to decimal and vice-versa in Python
- Convert string to DateTime and vice-versa in Python
- Converting string to number and vice-versa in C++
- Converting Strings to Numbers and Vice Versa in Java.
- C Program for LowerCase to UpperCase and vice-versa
- How to get ArrayList to ArrayList and vice versa in java?
- How to convert String to StringBuilder and vice versa Java?
- Convert from any base to decimal and vice versa in C++
- How to convert an array to Set and vice versa in Java?
- How to convert an integer to hexadecimal and vice versa in C#?
- C++ Program to Convert Binary Number to Decimal and vice-versa
- C++ Program to convert Octal Number to Decimal and vice-versa
- C++ Program to Convert Binary Number to Octal and vice-versa
- How to Convert a String to Hexadecimal and vice versa format in java?

Advertisements