Photo by Jay Wennington on Unsplash
List vs Set Data Structure
Use Set instead of List when finding for a key value
Table of contents
What is happening in List?
Python loops through the list until it locates the value or number that reaches the list's end. It is not effective.
### Code Snippet:
What is happening in Set?
Python will attempt to obtain the desired value or number directly rather than iterating through the list data structure and comparing each item to the desired value or number. It works much better.
### Output:
#Python #Programming #python #datatypes #Set #List