Post

@PythonPr B. The length of nums (which is the same as vals) is 5. The pop() method decreases 5 to 4. There are two append methods at bring the length up from 4 to 6.
English

vals = nums creates a pointer in memory to the same list. So whatever you do to vals is done to nums. So the pop reduces the length to 4. The 2 appends increases the length to 6. So the answer is B:
Here is my code which adds a couple of print statements and then adds a "is" test to both lists:
nums = [5, 10, 15, 20, 25]
vals = nums
vals.pop()
vals.append(30)
vals.append(35)
print("Length of nums is : " , len(nums))
print("Vals = :", vals)
print("Nums = ", nums)
print(vals is nums)
Here is the output:
Length of nums is : 6
Vals = : [5, 10, 15, 20, 30, 35]
Nums = [5, 10, 15, 20, 30, 35]
True
English

@PythonPr Every Python dev learns this the hard way. Once.
English

@PythonPr pop removes last element (25) by default
append 2more elements
print(len()) = 6
English

@PythonPr B) 6
vals.pop() removes the last element which decreases the len of nums from 5 to 4. Then we have two other numbers appended to the list to make len(nums) = 6
English














