I am trying to set a list = to another list and then sort the new list using .sort(). However, when I print them out to make sure they stored properly, both lists got sorted when I only set the new list to be. Why is this happening? The first print statement is printing the correct unsorted list, the third statement is correctly printing the new sorted list, but the fourth print statement is supposed to be printing the unsorted list but is printing a sorted list.
def twoSum(self, nums: List[int], target: int)->List[int]:
print("original list", nums)
sortedList = nums
sortedList.sort()
subset = []
answer = []
middle = math.floor((len(nums)/2))
print("middle is ", middle)
print("sorted list", sortedList)
print("unsorted list", nums)