I'm refactoring some scripts that have a bunch of code with like this:
if 'mString1' in mStrVar:
retVal = 1
elif 'mString2' in mStrVar:
retVal = 2
elif 'mString3' in mStrVar:
retVal = 3
elif 'mString4' in mStrVar:
retVal = 4
else:
retVal = 0
Personally I don't like this I always prefer the dict()
approach, but in this specific case, I think, I cannot be done in that way.
is it possible to rewrite this in a more short way? mString
goes around mString10
in some cases.
Any hints highly appreciated, and apologies if this is a duplicated I couldn't find any question related.