In: Computer Science
In Python Please
Dennis has always loved music, and recently discovered a
fascinating genre. Tautograms are a special case of alliteration,
which is the appearance of the same letter at the beginning of
adjacent words. In particular, a sentence is a tautogram if all its
words begin with the same letter.
For example, the following sentences are tautograms. French flowers bloom, Sam Serrano whistles softly, Pedro ordered pizza. Dennis wants to dazzle his wife with a romantic letter full of these kinds of prayers. Help Dennis check if each sentence he wrote is a tautogram or not. Input
Format Each test case is made up of a single line that contains a sentence. A sentence consists of a sequence of up to 50 words separated by individual spaces. A word is a sequence of up to 20 contiguous uppercase and lowercase letters of the English alphabet.
A word contains at least one letter and a sentence contains at least one word. The last test case is followed by a line containing a single character "*" (asterisk). Constraints For each test case, generate a single line that contains an uppercase "Yes" if the sentence is a tautogram, or an uppercase "No" otherwise.
Output Format "Yes or no"
#CODE TO COPY MAKE SURE INDENTATION IS CORRECT
def check_tautogram(sentence):
#spliting input sentense into words
words = sentence.split()
#getting first letter of first word
first_letter = words[0][0].lower()
check = True
#checking weather all the words haaving the same letter or
not
for i in words:
if (i[0].lower() != first_letter):
check = False
break
if check:
return 'Y'
else:
return 'N'
sentence = input()
while sentence != "*":
print (check_tautogram(sentence))
sentence = input()