CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List
Python Code Walkthrough #49

A Stack Made From A List

mediumData Structures & Algorithms

📄 Code

Read carefully — what does this print?
1stack: list[int] = []
2for value in [1, 2, 3]:
3 stack.append(value)
4print(stack)
5print(stack.pop())
6stack.append(9)
7print(stack.pop(), stack.pop())
8print(stack)
9print(len(stack))

🎯 Your Answer