πŸ“Š Python
Q. What will be the output of this code?
Code:
x = [1, 2, 3]
y = x
x.append(4)
print(y)
  • (A) [1, 2, 3]
  • (B) [1, 2, 3, 4]
  • (C) [4]
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) [1, 2, 3, 4]

Explanation: Both x and y reference the same list object, so changes via x reflect in y.

Explanation by: Mr. Dubey
Both x and y reference the same list object, so changes via x reflect in y.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
57
Total Visits
πŸ“½οΈ
11 mo ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
97%
Success Rate