won't this be much simplier?
def validate_string(string): spl = string.split(',') return all(word.count('=') == 1 for word in spl)