Created
October 29, 2017 17:07
-
-
Save mattstibbs/68f095e4cac509646768c4a7f5dcd811 to your computer and use it in GitHub Desktop.
RecentyUsedList - code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RecentlyUsedList(): | |
def __init__(self): | |
self.list_of_items = [] | |
def __len__(self): | |
return len(self.list_of_items) | |
def insert(self, item): | |
if item in self.list_of_items: | |
self.list_of_items.remove(item) | |
self.list_of_items.insert(0, item) | |
def __getitem__(self, index): | |
return self.list_of_items[index] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment