Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
you are reversing the whole string and adding 'ay' at the end, while output expected seems to be each word from the reversed string ending with 'ay'... rev = input()[::-1].split(' ') print(*[s+'ay' for s in rev]) I used: 1) split(' ') to split the reversed string 2) * here is the destructuring operator wich give each items (words) of the list as print() arguments (default separator is the space) 3) list comprehension to iterate concisely the list and add 'ay' to each words instead of 2) you could use ' '.join(the list comprehension) to build a string with space as joiner instead of 3) you could do a classical for..in loop and store the result in another variable holding a list... there are often (if not always) many ways to do ;P
20th May 2021, 11:43 PM
visph
visph - avatar