i
in the next
function is a local variable. It is always initialized to 0
when the function is called.
To make the variable i
remember the last value, make it as a global variable.
i = 0 # <--- global variable
def next():
global i # <--- declare `i` as a global variable
if (i<4):
i= i + 1
print (List[i])