modules clear_screen(function since the function is not defined inside another function (or inside class as we will see in the next it is still global functionaccessible like any other function in the module after creating the function we explicitly set its docstringthis avoids us having to write the same docstring in two placesand also illustrates that docstring is simply one of the attributes of function other attributes include the function' module and its name def resize(max_rowsmax_columnschar=none)"""changes the size of the gridwiping out the contents and changing the background if the background char is not none ""assert max_rows and max_columns "too smallglobal _grid_max_rows_max_columns_background_char if char is not noneassert len(char= _char_assert_template format(char_background_char char _max_rows max_rows _max_columns max_columns _grid [[_background_char for column in range(_max_columns)for row in range(_max_rows)this function uses an assert statement to enforce the policy that it is coding error to attempt to resize the grid smaller than if background character is specified an assert is used to guarantee that it is string of exactly one characterif it is notthe assertion error message is the _char_assert_template' text with the { replaced with the given char string unfortunatelywe must use the global statement because we need to update number of global variables inside this function this is something that using an object-oriented approach can help us to avoidas we will see in list comprehensions the _grid is created using list comprehension inside list comprehension using list replication such as [[charcolumnsrows will not work because the inner list will be shared (shallow-copiedwe could have used nested for in loops instead_grid [for row in range(_max_rows)_grid append([]for column in range(_max_columns)_grid[- append(_background_charthis code is arguably trickier to understand than the list comprehensionand is much longer