I want to find out whether two numbers N1 and N2 are the permutations of the same digits. For example 123
and 321
There is no need to do anything with global values here. Everything should be contained within the function.
The problem is simply that you don't define arr1
or arr2
before you try appending to them. You need to define them in that function, along with s1
, s2
, k
and fl
.
Edit I should add that your code is extremely unPythonic. All these while loops with incrementing counters should be replaced with for loops: for k in range(10)
etc. But the first loop isn't even necessary - you should have arr1 = [0] * 10
and the same for arr2
.