Skip to main content
2 of 5
added 703 characters in body
Grajdeanu Alex
  • 9.3k
  • 4
  • 32
  • 71

Nice PEP8 compliant code, Phrancis. Good job! I only have two comments to make regarding that: you usually have to use triple-double quoted strings when it comes to docstrings. From the docs (PEP257):

For consistency, always use """triple double quotes""" around docstrings. Use r"""raw triple double quotes""" if you use any backslashes in your docstrings. For Unicode docstrings, use u"""Unicode triple-quoted strings""" .

More, you missed one newline between your imports and the first function. It's not such a big deal but I thought it's worth mentioning it.

In this line:

...
return file_.read().replace("\"", "").split(",")

You can use single quotes to get rid of the escape character \:

return file_.read().replace('"', '').split(',')

You can also omit the read file mode as that's the default mode when you read a file:

with open(file_path) as file_:
    ...

There's more than one place where you wrote:

something = list(string)

Instead of the situation where you sorted the list, you don't need list(string) because you can already iterate a string just fine.

###Use enumerate() more often.

You can rewrite your get_alpha_values() function like this:

def get_alpha_values() -> Dict:
    alpha_values = {}
    for index, letter in enumerate(string.ascii_uppercase, 1):
        alpha_values[letter] = index
    return alpha_values

Enumerate takes a second argument which lets you start from whatever position you want (in our case, that would be 1).

Grajdeanu Alex
  • 9.3k
  • 4
  • 32
  • 71