Say I have a string that can contain different characters:
e.g. word = "UPPER£CASe"
How would I test the string to see if all the charac
You can alternatively work at the level of characters.
The following function may be useful not only for words but also for phrases:
def up(string):
upper=[ch for ch in string if ch.isupper() or ch.isspace()]
if len(upper)==len(string):
print('all upper')
else:
print("some character(s) not upper")
strings=['UPPERCAS!', 'UPPERCASe', 'UPPERCASE', 'MORE UPPERCASES']
for s in strings:
up(s)
Out: some character(s) not upper
Out: some character(s) not upper
Out: all upper
Out: all upper