I am new to Python. I declared a variable named 'total' outside the function and then I called it inside my function called 'my_function'. But it is giving me an error because my variable 'total' is not global. Why is that? I thought variables declared outside were already considered global.
total = 1
def my_function(list):
    for i in list:
        total = total + 1
        print (total)
my_function([1,2,3])

 
    