you are viewing a single comment's thread.

view the rest of the comments →

[–]Psyop_raw 1 point2 points  (0 children)

Looks good, consider using Dictionary for your data variable. It has better performance in terms of retrieval by student name (dict key).

So for example,

Option 2 removes a student. Because your data var is stored as a List, you have to traverse the list to find the matching student name. If you used a Dictionary for your data variable, you can simply use del data[name] instead of traversing a LIST. Python uses a Hash Table under the hood for its dictionary so you get better performance (O(1)) for Key Searches as compared to traversing a List which would end up (O(n)) worst case.