... because you are trying to import iterator
, which does not exist?
Edit:
Have you tried either
from itertools import islice
or
all_decisions.extend(itertools.islice(reader,4))
Question
I am trying to use the islice function but am getting the following error:
Traceback (most recent call last):
File "/Users/gavinnachbar/Session 3 copy/all_in_one_almost.py", line 168, in <module>
all_decisions.extend(islice(reader,4))
NameError: name 'islice' is not defined
I have imported itertools but am still getting the error, any idea why?
La solution
... because you are trying to import iterator
, which does not exist?
Edit:
Have you tried either
from itertools import islice
or
all_decisions.extend(itertools.islice(reader,4))
Autres conseils
Q. I have imported itertools but am still getting the error, any idea why?
A. Yes. When you import itertools
, you need to write itertools.islice
instead of just islice
.