To print a particular folder name in python?
Question: I've made a script in python which scans all the folders and sub-folders and
then prints all the folders and subfolders which begin with the word Hello.

Now I need to implement a change which is that I should be able to print any
folder which has the word Hello. Like the word could be hiHello or
abcHelloxyz. So this folder must also be printed. I guess the grep command
needs to be used.

    
    
    import os
    
    if os.path.isdir('/'):
        for root, dirs, files in os.walk('/'):
            for name in dirs:
                 if name.startswith(("hello")):
                     print ("\n\nFile Name: "+ name)
                     name = os.path.abspath(os.path.join(root, name)
    )       
                     print ("Path     :"+name)
    


Answer: You can test if `'Hello'` is a substring in the `dirname` using `'Hello' in
dirname`:

    
    
    In [1]: dirname = 'hiHello'
    
    In [3]: 'Hello' in dirname
    Out[3]: True
    
    In [4]: dirname.startswith('Hello')
    Out[4]: False
    

