Jun-07-2021, 09:00 PM
Please consider the following Python code:
the global variable are the same. I do not see anything wrong with this. Is there something I am missing?
def my_sum(array): ret = 0 for i in range(len(array)): ret += array[i] return ret array = [ 1,2,3,4] print( "sum is " + str(my_sum(array)) )In this case, the code analyzer from Spyder generates a warning because the name of the parameter and the name of
the global variable are the same. I do not see anything wrong with this. Is there something I am missing?