- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
Why python returns tuple in list instead of list in list?
Python expects you to not mutate data when it returns some data. Tuples are also faster than lists. Tuples are generally used where order and position are meaningful and consistant. So for example, if you have a database driver in python and query for some data, you'll likely get back a list of tuples as the driver expects you to get the data and use it not mutate it. This also ensures that the data is in the same order as the fields you queried.
Advertisements