What is difference between tuble & list? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

What is difference between tuble & list?

2nd Jun 2017, 5:26 AM
Nithya Mk
Nithya Mk - avatar
6 ответов
+ 9
List -> Mutable Tuple -> Immutable
2nd Jun 2017, 11:58 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 3
A list is an array of same or dissimilar objects(can be a collection of strings, integers etc) and it can be modified in the sense its contents can be deleted or modified as well as new contents can be added as well whereas in a tuple once you declare and define it it's content cannot be modified or deleted and new content cannot be added. Tuple is fixed once it's created. Tuple-> Immutable List-> Mutable Also execution of tuples is faster than lists. Cheers!!
2nd Jun 2017, 5:39 AM
PRITISH DAS
PRITISH DAS - avatar
+ 1
tuple is (1,2,3 ) also you cannot change objects in tuple while list is [1,2 3] and you can change objects In list .. speed for processing tuple is faster than list
9th Jun 2017, 9:45 AM
nikhil
nikhil - avatar
+ 1
Here is my primer on tuples in Python - hope you find it useful! https://code.sololearn.com/cce88fWlK7L7/?ref=app
26th Apr 2018, 6:29 PM
Johannes
Johannes - avatar
0
Its also worth noting that tuples are smaller in file size and faster to execute than lists. if you had these two programs: lst1 = [1, 2, 3] print(lst1) VS: tple1= (1, 2, 3) print(tple1) You'd find the program with the tuple executed faster and had a smaller file size. So its probably good practice to use a tuple in place of a list if you dont need the extra functionality of a list.
2nd Jun 2017, 10:59 AM
Spock
Spock - avatar
0
tuples are inmutables list not, lista are mutables
4th Jun 2017, 4:09 PM
Celso Vicente
Celso Vicente - avatar