Connected interview question

Python data structure