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
Using regular expressions:
import re if re.search('[^abc]', string): print('wrong character')