Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

difference between set and list in python

'''
In python, a list is a collection of values in a specific order.
There can be several times the same value
[4,8,9,5,4,1,3,4] is a valid list in python

In a set, all values have to be unique
and there is no order like in a list or a tuple.

It is better to use sets compared to lists as much as possible,
because of its speed to retrieve data and space memory economy.
For instance, if you want to store usernames, a set is better than a list
because you don't care about the order and usernames are supposed to be
unique.

Diferent methods are available for sets and lists.
I will let you discover them on this well-done website : 
https://www.datacamp.com/community/tutorials/sets-in-python
'''
Source by www.datacamp.com #
 
PREVIOUS NEXT
Tagged: #difference #set #list #python
ADD COMMENT
Topic
Name
5+8 =