I did it in a simpler way to make it easier for you to understand:
Putting the sentence in all minuscule letters to avoid comparison error:
frase = 'Dentro desta devassa desilusão, Deixaste dias dourados de desalentos, Decorados de déspota dor.'.lower()
Splitting the string into slices to form a word list:
palavras = frase.split(' ')
If a letter other than the initial script stops, if it matches it continues running and counting the initial letters:
Edit:
As hkotsubo’s suggestion, removing the contactor is more readable and easy to understand:
frase = 'Dentro desta devassa desilusão, Deixaste dias dourados de desalentos, Decorados de déspota dor.'.lower()
palavras = frase.split(' ')
for palavra in palavras:
if palavra[0] != frase[0]:
print('A frase não é um Tautograma.')
break
else:
print('A frase é um Tautograma.')
Another way more 'advanced':
frase = 'Dentro desta devassa desilusão, Deixaste dias dourados de desalentos, Decorados de déspota dor.'.lower()
palavras = frase.split(' ')
len(palavras) == len([i for i in palavras if i[0] == frase[0]])
Returns True if it is a Tautograma and False if it is not.
Important you [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of the problem and attempt to solve. To better enjoy the site, understand and avoid closures and negativities worth reading the Stack Overflow Survival Guide in English and What a mistake I made in asking my question.
– Bacco