Question DSA-STK-0004
EasyWhat is the output of this code?
s = []
s.append(1)
s.append(2)
s.append(3)
print(s.pop())
- A.
2
- B.
3
- C.
Show answer and explanation
Answer: B
pop() removes and returns the last element pushed, 3.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Stacks question
What is the output of this code?
s = []
s.append(1)
s.append(2)
s.append(3)
print(s.pop())
2
3
Answer: B
pop() removes and returns the last element pushed, 3.
[1, 2]
1