for some reason the variable "a" in the main function changes after the function call. In spite of the fact that "a" doesn't even change within the function. Although even if it did, such changes should not affect its value outside the function, right?
I am using Python 3.6, and I'm out of ideas as to why this is happening. Any help would be greatly appreciated
def mhmArgSort(myNumListInput):
myNumList=myNumListInput
cnt=0
endCnt=len(myNumList)
NumListSortedIndices=[]
for cnt1 in range(len(myNumList)):
smallestNum=100000000000
smallestNumIndex=0
for cnt in range(len(myNumList)):
if myNumList[cnt]<smallestNum:
smallestNum=myNumList[cnt]
smallestNumIndex=cnt
NumListSortedIndices.append(smallestNumIndex)
myNumList[smallestNumIndex]=100000000000
return NumListSortedIndices
a=[1,2,3,4,-1,0,3]
print(a)
b=mhmArgSort(a)
print(a)
print(b)
This produces the following result:
[1, 2, 3, 4, -1, 0, 3]
[100000000000, 100000000000, 100000000000, 100000000000, 100000000000, 100000000000, 100000000000]
[4, 5, 0, 1, 2, 6, 3]