Difference between list and set Python
December 2, 2017 HomeCode SnippetsDifference between set and list in python Difference between set and list in pythonByMohammed Abualrob Code Snippets, Math and Probability, Technical Differences 0 Comments Set vs list in Python A better way to understand the key difference between sets and lists in Python is to understand the definition regardless of language or syntax. Generally speaking, a set is a mathematical concept which refers to a collection of distinct objects (in math they are called elements). Distinct means there are no duplicates and a collection means there is no order for individual elements. On the other hand, a list is essentially an array. An array can have duplicate elements and each element has an order or an index within the array. That is the main difference, let us now be more specific Set properties in Python
List properties in Python
So, the main differences are: order, uniqueness of elements and performance. You can find below a couple of examples demonstrating how to use sets and list in Python: Set examples Python
List examples Python
When to use a set?
When to use lists?
Summary Here is a tabular summary of differences between sets and lists in Python
References
More from my site
Tags:Python About AuthorMohammed AbualrobSoftware Engineer @ Cisco Add a CommentCancel replyYour email address will not be published. Comment:* Name:* Email Address:* Website: Save my name, email, and website in this browser for the next time I comment.
Δ |