Itertools library | Sololearn: Learn to code for FREE!

+3

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

Haider

5 Answers

New Answer

+5

Haider It should look like this and work both in PyCharm and Sololearn: https://code.sololearn.com/cQQJt6czq4MZ/?ref=app

+4

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

+1

Anna thank you.

0

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

0

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