I\'m wondering if there is more elegant way to check if the string (str = \'abcccbbaabcbca\') contains only \'a\',\'b\' or \'c\' than iterating over it :
for
You could use any with a generator expression:
if any(c not in 'abc' for c in _str): # Don't use str as a name. print('Wrong character')