I have a directory that contains directories like /sample1, /sample10, /sample11 etc.
when I am using os.walk
to access all of them one by one, I am facing some difficulties.
for root, dirs, files in os.walk(mypath):
if 'sample1' in root:
print root
now, this returns all root /sample1, /sample10, /sample11 etc. as 'sample1' is there for all directories. how can I obtain only sample1 directory ?
may be regex would be good but I dont know how to use it.