The error displayed in the following Python code is? [code]import itertools l1=(1, 2, 3) l2=[4, 5, 6] l=itertools.chain(l1, l2) print(next(l1))[/code]

The error displayed in the following Python code is?
Code:
import itertools
l1=(1, 2, 3)
l2=[4, 5, 6]
l=itertools.chain(l1, l2)
print(next(l1))
A. ‘list’ object is not iterator
B. ‘tuple’ object is not iterator
C. ‘list’ object is iterator
D. ‘tuple’ object is iterator
 
Answer: b
Explanation: The error raised in the code shown above is that: ‘tuple’ object is not iterator. Had we given l2 as argument to next, the error would have been: ‘list’ object is not iterator.
 

Tìm kiếm

Back
Top