generate functionThu, 02 Mar 2023

Enter a list of student names in one line separated by a space. Determine that at least one name in this list starts and ends with the same letter (case insensitive). Implement the program using a while loop and a break statement. Print YES if the condition is met and NO otherwise.

def check_same_letter(names): first_letter = '' for n in names: if n[0] == n[-1]: first_letter += n[0] break return first_letter != '' check_same_letter(['molly', 'jordan'])

Questions about programming?Chat with your personal AI assistant