There is a line, you need to define in it those words that begin and end with the same letter.

Tell me how to be.

  • one
    Probably break the line into words, and check the first and last letter of each word. Access to individual letters in a word can be obtained in the same way as you access the elements of the list. - Andrey
  • s = input () q = s.split ('') for k in q: if k [0] == k [-1]: print (k) - Imao
  • everything is fine, thank you very much! did not know about such a function - Imao February

2 answers 2

s = '...' words = [i for i in s.split() if i[0] == i[-1]] 
     words = your_string.split() # Разбиваем строку по пробелам на слова answer_words = list(filter(lambda x: x[0] == x[-1], words)) # Фильтруем от слов, у которых последний (-1) символ отличается от первого (0)