Itertools library | Sololearn: Learn to code for FREE!


Itertools library

Import takewhile from itertools in Pycharms.But it shows following error NameError: name 'takewhile' is not defined. Any solution??

2/5/2019 4:38:13 PM


5 Answers

New Answer


Haider It should look like this and work both in PyCharm and Sololearn:


Import it like this: "from itertools import takewhile". Then you can use "takewhile" in your code. Don't write "itertools.takewhile"


Anna thank you.


// Zohir I am not using Sololearn Code Playground instead using Pycharm


Anna, I import the same way,but the problem persists