How to append an element in a list a declared in global , while list.append() statement is inside a function
corrected code for query , both var and result are global variables which are required to be accessed inside a function
import copy result =  var = 'second list empty' def permute(arr1,arr2): if(len(arr2) <= 0): global result.append(var) return stx = "".join(arr1) for x in arr2: var = stx + x arr3 = copy.deepcopy(arr2) arr3.remove(x) permute(var.split(),arr3)
Remove the word global from your append statement.
It should be:
You only need the global keyword when you`re reassigning a global variable inside the function, and you use it just to declare the variable global; you can't do anything else with it in that statement.