I have a variable aName that contains a string, like googabc_android It is generated in a for loop that loops through thousands of files to generate that string.
I have two if statement blocks that checks the aName variable and replaces the text in it.
The first if statement block is like this:
if aName.split('_')[1] == "android":
aName = aName.replace('_android','Android')
And similar values for ios / windows etc.
The second if statement block checks if abc is in the string and replaces it to a relevant value. As there are many cases, it is a long block.
I want the two if statement blocks to run consecutively, so I have decided to put them in separate functions. However, as aName is generated when the loop runs, my functions are unable to get the variable. I cannot use return as the function has to run to its completion for my output to work.
I have tried using yield but the function just ends there.
How do I get aName and pass it through my other functions?
Aucun commentaire:
Enregistrer un commentaire