I'm trying to change the referenced value nums in removeDuplicates
function.
So after the function is called, test
can have [1, 2, 3, 4, 5]
.
But the result is test
still have [9, 8, 7, 6]
. Is there a way modify with assignment?
class Simple:
def removeDuplicates(self, nums: List[int]) -> int:
nums = [1, 2, 3, 4, 5]
print("in function: ", nums)
simple = Simple()
test = [9, 8, 7, 6]
simple.removeDuplicates(test)
print("after function: ", test)
Result:
in function: [1, 2, 3, 4, 5]
after function: [9, 8, 7, 6]