python tuple vs list code example
Example 1: python tuple vs list
#tuples and lists are the same thing, but a tuple cannot be changed
tup = (1,'string',True)
lst = ['hiya',23545,None]
Example 2: list vs tuple python
mylist : list = [] # <-- a list variable can be defined either as [] or <varname> : list
mytuple : tuple = () # <-- a tuple variable can be defined either as () or <varname> : tuple
Example 3: python tuple and list time compare
import timeit
print(timeit.timeit('x=(1,2,3,4,5,6,7,8,9)', number=100000))
print(timeit.timeit('x=[1,2,3,4,5,6,7,8,9]', number=100000))