"dict" is not a good variable name in Python

  • 6

    I know the idea is to have the same variable names in different languages so people can understand other people's algorithm more easily.

    However, dict is a built-in class name in Python. So using dict as a variable name does not sound like a good idea to me in Python. I suggest changing it to "dictionary" here.

  • 0

    It's true, but it doesn't matter when you use it as a variable name unless you want to use dict to create an object as a class.

  • 0

    agree, workaround for now is to use my_dict = {} rather than my_dict = dict()

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.