vendredi 4 décembre 2020

If a specific string is found, set as variable

I'm trying to assign a variable to a specific member of a list if it's found, but need to assign it to the human readable string first.

The original list is not human readable but can be interpreted using an API's GetName() function.

So to get my original list:

subFolders = rootFolder.GetSubFolderList()

To get that list as human readable:

for sub in subFolders:
    print(sub.GetName())

Now I'm trying to assign the variable 'Mmedia' if the string '02_media" is found in the human readable list.

for Mmedia in subFolders:
    if Mmedia.GetName == '02_media':
        print('there is an 02_media folder')
else:
    print('no folder found')

any thoughts are really appreciated.

Aucun commentaire:

Enregistrer un commentaire