Python_Institute
PCEP-30-02 · Question #312
What is the expected output of the following code? ``python data = [1, 2, [3, 4], [5, 6], 7, [8, 9]] count = 0 for i in range(len(data)): if type(data[i]) == list: count += 1 print(count) ``
The correct answer is D. 3. See the full explanation below for the reasoning.
Question
What is the expected output of the following code?
data = [1, 2, [3, 4], [5, 6], 7, [8, 9]]
count = 0
for i in range(len(data)):
if type(data[i]) == list:
count += 1
print(count)
Options
- A6
- BThe code is erroneous.
- C9
- D3
How the community answered
(27 responses)- A11% (3)
- B7% (2)
- C4% (1)
- D78% (21)
Community Discussion
No community discussion yet for this question.