0

I have a python program and in my program, I want to manipulate folder and subfolders. When I use subfolders = next(os.walk(src))[1] command, I get this error:

StopIteration

I have no idea about this error. I print the path before rising the error and the path is valid.

Stateless
  • 293
  • 2
  • 4
  • 18
  • Apparently, `src` does not exist. Do a print to see what it is. – zondo May 25 '17 at 13:37
  • This post might be of help to you https://stackoverflow.com/questions/37289653/os-walk-error-of-unhandled-stopiteration – Girrafish May 25 '17 at 13:40
  • To understand this in more depth, python iterators will raise a StopIteration exception when they are empty. So in effect what is happening is the iterator is out of available items. – pypypy May 25 '17 at 13:43
  • @zondo As I said in my question, I am printing src content and this is a valid path. – Stateless May 25 '17 at 13:44
  • @pypyoy unfortunately I could not get a list if my subdirectories in my giving path. – Stateless May 25 '17 at 13:57

0 Answers0