Skip to content
CodeKruPro

+= on a list versus a tuple

QuizMediumPython onlyAsked in: Infosys

What does this print?

l1 = [1]
l2 = l1
l1 += [2]
t1 = (1,)
t2 = t1
t1 += (2,)
print(l2, t2)
  • [1, 2] (1,)
  • [1] (1,)
  • [1, 2] (1, 2)

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in