← Quiz: References and Copying: all 10 questions
Quiz: References and Copying · Question 1 of 10
What does this print? (code)
What does this print?
a = [1, 2]
b = a
b.append(3)
print(a)
- A.[1, 2]
- B.[1, 2, 3]
- C.[3]
- D.An error
Answer & explanation
Correct answer: [1, 2, 3]
b = a makes b a second name for the same list, so the append is seen through a.
Can you get the rest right without peeking?
Take the timed Quiz: References and Copying quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →