path.exists()
just returns True
or False
depending on if that path exists. You should first check its existence via exists()
, then use os.listdir()
or glob.glob()
to actually get a list of items in that path, but only if exists()
returned True
.
solved Python – OS Module ‘TypeError: ‘bool’ object is not iterable” [closed]