Global name in Python

后端 未结 2 1924
别跟我提以往
别跟我提以往 2021-01-05 09:01

I want to find out whether two numbers N1 and N2 are the permutations of the same digits. For example 123 and 321

2条回答
  •  一整个雨季
    2021-01-05 09:27

    You need to define the arrays in the functions. And then append to it. arr1 = [] defines an empty array.

    arr1[k] = 2
    

    tries to change the value at index k. So either you should initialise it to a certain size or append to the empty array (using the append function).

    Also, if you want to access the arrays from outside the function, you might want to return the arrays from the function

提交回复
热议问题