+ 16
What is the difference between tuple and list in python??
12 Antworten
+ 4
hello! its a very nice question, most of people often have the same query.
and i myself had the same question when i started Python.
...
for being a little bit funny....😂the difference is in the syntax declaration.
important differences.
in pyhton
there are 3 main sets method namely
1. List
2. Tuple
3. Dictionary
as per your question
List in Python is mutable [mean the data in list can be modified during the program.]
where as..
Tuple in Python follow immutability (means once the values are allocated to the index it cant be changed throughout the program.)
and in regards for dictionary which have not asked, if you need any help there i will be happy to help you there.
thank you.
+ 8
1) List in Python can be edited...
as we can use append function in list to add new items in the list.
On the other hand we cannot use append function in case of Tuple.
2) We cannot use del function to delete any part of the Tuple but we can use del function to delete any part of the list in Python.
If you need furthur help then ask.
+ 4
Check this good article about:
https://nedbatchelder.com/blog/201608/lists_vs_tuples.html
+ 2
Tuple is a list that cannot be modified (No adding, removing or replacing elements of a tuple).
+ 1
They are varied in their literal,size,operation and usage
LITERAL:
e.g. egtuple=(1,2)
eglist=[1,2]
SIZE:
e.g. a=tuple( range(1000)) #8024-->>So,tuples are small,fast
b=list(range(1000)) #9088
OPERATION:
You can't delete or sort a tuple
USAGE:
List is mutable
Tuple can be used as a key in dictionary
0
tuple can't edite
0
As others said, the tuples are immutable types and cannot be changed once created.
0
Tuples are constant data types that can't be manipulated nor changed. lists can be. They can each serve different types of functions within your data structure.
0
tuples are immutable while list are
0
tuple can changed but list are permanent it can't be changed
tuples is denoted in (. )
list is denoted in [. ]
0
What could be described as an immutable list?
- 3
What could be described as an immutable list?