list vs tuple

Solutions on MaxInterview for list vs tuple by the best coders in the world

showing results for - "list vs tuple"
Abrielle
13 Oct 2018
1#tuples and lists are the same thing, but a tuple cannot be changed
2tup = (1,'string',True)
3lst = ['hiya',23545,None]
Célestin
25 Jul 2017
1mylist : list = [] # <-- a list variable can be defined either as [] or <varname> : list
2mytuple : tuple = () # <-- a tuple variable can be defined either as () or <varname> : tuple
Millicent
19 Jul 2016
1# compare the size
2import sys
3my_list = [0, 1, 2, "hello", True]
4my_tuple = (0, 1, 2, "hello", True)
5print(sys.getsizeof(my_list), "bytes")
6print(sys.getsizeof(my_tuple), "bytes")
7
8# compare the execution time of a list vs. tuple creation statement
9import timeit
10print(timeit.timeit(stmt="[0, 1, 2, 3, 4, 5]", number=1000000))
11print(timeit.timeit(stmt="(0, 1, 2, 3, 4, 5)", number=1000000))
12
Jacob
09 Feb 2016
1import timeit
2print(timeit.timeit('x=(1,2,3,4,5,6,7,8,9)', number=100000))
3
4print(timeit.timeit('x=[1,2,3,4,5,6,7,8,9]', number=100000))
queries leading to this page
python tuple vs listobjects vs tuplespython tuple notation versus listwhat is the difference between a python tuple and python listdifference between list and tuple in hindituples vs lists pythonlist vs tuple differencelist vs tupleshat is the difference between a python tuple and python listpython tuple vs lstpython typle vs listpython tuple differencepython list versus tuplepython tuple and list time comparewhat is an important difference between lists and tuples in pythonpython tuple or listpython tuples vs listspython 28 29 vs listpython 27s tuples advatage over arraylist of depths pythontuples vs lists in pythonlist vs tuple in pythonwhen to use tuple vs listtuple versus list pythonlist in python vs tupledifferences between lists and tupleslist vs tuple in python with examplelists vs tupleslist vs tuplecompare tuple and list pythondifference between tuple and lsitslist vs tuple pythobnlists vs tuples pythonpython set vs tuple vs listpython difference between list and tuplepython list or tupledifference between tuples and lists in pythonpython str listlist vs tuple vs set pythonwhy are tuples used in pythontuple vs listpython list vs tuple vs setwhat are the difference between list and tuple in python 3fpython 3 list tuple comparisiontuple vs list vs distlist and tuplediff btwn tuple an dlistcompare list and tuple in pythontuples vs listlist and tupleshow to compare elements in list and tuples in pythontupple vs list pythonlist vs tuple typetuple vs tuple pythonlist vs tuple comparisonpython list vs tuplepython when to use list vs tuplewhat are tuples used for in pythonwhat is a tuple vs listcompare and contrast tuples with listtuple in python vs list pythondifference between tuple and list in pythondifference between tuple and listtuple in python vs listdifference between list and tuplepython sets vs lists vs tupleslists vs tuples in pythontuples vs listelist vs tuple tuple vs list pythontuple vs list functionspython tuples instead of listslist and tuple in pythontuple or list pythonpython set vs list vs tuplewhen do we use tuples in pythonlit of tuples instead of tuple of listsstate the difference between tuples and lists in pythonpy list vs tuplepython 3 tuple vs listtupple vs listdifference of tuple variables pythontuple list differencedifference between python tuple and listwhats the doffernece between a list and a tuple in pythontuples python vs listtuple vs list pywhen to use a tuple vs a listpython lost vs tupleis a tuple in list pythondifference between list and tuple in pythonlist vs tuple pythonpython listvs tuplepython list vs tuple examplepython tuple vs lsitdifference between list 2c tuple and array in pythonlist and tuple differencelist with tuples or not pythonwhen to use tuples and when to use liststuple vs list in pythondifferences between tuples and lists in pythonarray vs list vs tuple in pythondiff between list and tuplewhat is a list vs tuple in pythontuple vs seriesdifference between tuple and list pythonwhat is tuple vs list in pythonwhy to use tuples instead of listswhat is the difference between list and tuples in python 3fpython list vs tuple vslist vs tuple pythhonpython lists vs tupleslist vs tuple difference pythonwhen to use tuple vs list in pythonset vs list vs tupletuples vs listspython list vs tuplestuple vs list pyhtonpython list tuplehow is a list different than a tuple 3fdifference between tuple and list 3fpython tuple vs list vs setpython declare list vs tuplepython tuple differemcetuple python vs listlist vs tuple