I have a string like this
>>> x=\"Alpha_beta_Gamma\"
>>> words = [y for y in x.split(\'_\')]
>>> words
[\'Alpha\', \'beta\', \'Gam
You can use this code:
def is_valid(string):
words = string.split('_')
for word in words:
if not word.istitle():
return False, word
return True, words
x="Alpha_beta_Gamma"
assert is_valid(x)==(False,'beta')
x="Alpha_Beta_Gamma"
assert is_valid(x)==(True,['Alpha', 'Beta', 'Gamma'])
This way you know if is valid and what word is wrong