Hi!
I'm coding a program that's supposed to solve Sudoku, but came accross a really odd behaviour of lists.
comparelist is a 2D list (9 x 9) filled with integers and unsorted (and I want it to stay that way)
>for i in range(9):
>>> bufferlist=comp arelist[i]
>>> bufferlist=sort er.sortiere(buf ferlist,0,len(b ufferlist)-1) # sorts a list
>>> if bufferlist==che cklist:
>>>>> count2=count2+1
>print comparelist
now, the bufferlists are all being sorted properly, but the comparelist is now sorted as well !! Why is that so? I really don't understand that behaviour, since I don't say to put the sorted bufferlist back into the comparelist.
Someone help me please. And thanks in advance :)
~Mo
I'm coding a program that's supposed to solve Sudoku, but came accross a really odd behaviour of lists.
comparelist is a 2D list (9 x 9) filled with integers and unsorted (and I want it to stay that way)
>for i in range(9):
>>> bufferlist=comp arelist[i]
>>> bufferlist=sort er.sortiere(buf ferlist,0,len(b ufferlist)-1) # sorts a list
>>> if bufferlist==che cklist:
>>>>> count2=count2+1
>print comparelist
now, the bufferlists are all being sorted properly, but the comparelist is now sorted as well !! Why is that so? I really don't understand that behaviour, since I don't say to put the sorted bufferlist back into the comparelist.
Someone help me please. And thanks in advance :)
~Mo
Comment