since you could always use
def string_to_lower(s :: str) -> str: return s.lower()
Write docstrings for all functions, including helper and nested functions.
A good docstring gives a description of the function, including its input(s) and output. Ideally, by looking at the docstring you know what the function does and how to use it without looking at the function body itself.
Give constants and helper functions useful names.
All functions require type annotations on inputs and output. You can omit output annotation for functions that have no return (for example functions that only need to
Names of constants and functions should be lower case and underscore separated. For configuration constants (for example the height of a character) it is acceptable to use all caps names.
Keep lines under 120 characters.
Indent your code properly. If you are using Pycharm, this should be happening automatically. If you are not using Pycharm, use 4 spaces to indent your code (not the tab character) and keep arguments of functions lined up:
def func_name(long_parameter_1 : int, long_parameter_2 : str long_parameter_3 : list, long_parameter_4 : list) -> int: ... func_name(long_argument_1, long_argument_2, long_argument_3, long_argument_4)
returnstatements should be not be written like this:
but rather like this:
ifstatements should be written with newlines:
if condition1: print('condition1') elif condition2: print('condition2') else: print('condition3')