Leetcode Design Hashmap Python Syntax If Loop