Jun-07-2021, 09:00 PM
Please consider the following Python code:
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?
1 2 3 4 5 6 7 8 |
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)) ) |
the global variable are the same. I do not see anything wrong with this. Is there something I am missing?