Assigned before the reference a local variable "max"
after the internal variable assignment function to modify the variable it will be regarded as Python interpreter local variable instead of global variables, the program execution when the max = max (nums [: k ]) when want to perform max is considered local variables defined within the function can not find the max of the natural error
Solutions: Inside the function, to add global variable modifier, it is declared as a global variable
However, I added a global max is still wrong after
the original variable and function names max () the same name
so the max variable name changed to maxa