That is because the list sort method sorts in place and returns None
@menator01 Your code has two variables list1 & list2 that point to the same list object
list1 = [3, 4, 1, 2] list2 = list1.sort() print(list1) print(list2)
Output:[1, 2, 3, 4]
None
Use sorted if you want to get a sperate sorted versionlist1 = [3, 4, 1, 2] list2 = sorted(list1) print(list1) print(list2)
Output:[3, 4, 1, 2]
[1, 2, 3, 4]
@menator01 Your code has two variables list1 & list2 that point to the same list object
list1 = [3, 4, 1, 2] list2 = list1 list2.sort() print(list1) print(list2)
Output:[1, 2, 3, 4]
[1, 2, 3, 4]