Skip to main content
2 of 3
added 205 characters in body
Madagascar
  • 10.1k
  • 1
  • 16
  • 52

Use type-hints:

def phone(strng, num):

At first glance (I hadn't read the problem specification yet), I had incorrectly inferred from the names that the first parameter was of type str and the second of type int. That wouldn't have been the case had you annotation them:

def phone(strng: str, num: str) -> str:
    ...

Additionally, strng is too generic, phonebook or phonebook_lines would be more self-explanatory.

The name of the function phone is quite vague as well. It doesn't specify what the function does, and we are missing a docstring as well.

Use an automatic code-formatter:

Whitespace is free to use. You have been too stingy with it. The indentation is all over the place. Consider using black or ruff to format it according to PEP-8.

Missing test cases:

I do not see any unit tests. I'd have expected at least a main() function to exercise its correctness.

Madagascar
  • 10.1k
  • 1
  • 16
  • 52