Let’s step through the code.
D is a dictionary: {1: "ONE", 2: "TWO", 3: "THREE"}
L1 and L2 are empty lists.
Function Change(D) is called.
Inside the function:
- For each key-value pair in D,
- K is appended to L1,
- V is appended to L2.
So the iterations go like this:
- K = 1, V = "ONE" → L1 = [1], L2 = ["ONE"]
- K = 2, V = "TWO" → L1 = [1, 2], L2 = ["ONE", "TWO"]
- K = 3, V = "THREE" → L1 = [1, 2, 3], L2 = ["ONE", "TWO", "THREE"]
D is not changed inside the function.
Output:
[1, 2, 3]
['ONE', 'TWO', 'THREE']
{1: 'ONE', 2: 'TWO', 3: 'THREE'}