Shallow copy or deep copy?
QuizMediumPython onlyAsked in: Infosys, TCS
What does this print?
import copy
nested = [[1, 2], [3]]
sh = copy.copy(nested)
dp = copy.deepcopy(nested)
nested[0].append(99)
print(sh, dp)[[1, 2, 99], [3]] [[1, 2], [3]][[1, 2], [3]] [[1, 2], [3]][[1, 2, 99], [3]] [[1, 2, 99], [3]]
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.