What is an efficient way to check that a string s in Python consists of just one character, say \'A\'? Something like all_equal(s, \'A\')
s
\'A\'
all_equal(s, \'A\')
You could convert to a set and check there is only one member:
len(set("AAAAAAAA"))