Hi, I wrote this code to solve a problem, can someone say me if there is a shorter or easier way to do it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Hi, I wrote this code to solve a problem, can someone say me if there is a shorter or easier way to do it?

If a sentence flows, the first letter of each word will be the same to the last letter of the previous word. Task: Write a program that takes in a string that contains a sentence, checks if the first letter of each word is the same as the last letter of the previous word. If the condition is met, output true, if not, output false. Casing does not matter. Input Format: A string containing a sentence of words. Output Format: A string: true or false. Sample Input: this string gets stuck Sample Output: true Here's the code https://code.sololearn.com/cLXbF8PftpOo/?ref=app

28th Jul 2022, 10:29 AM
Edo
Edo - avatar
4 Answers
- 1
Please describe what the code is supposed to do and what input you expect.
28th Jul 2022, 10:42 AM
Lisa
Lisa - avatar
- 1
Done
28th Jul 2022, 10:48 AM
Edo
Edo - avatar
- 1
Where is this task from? 🤔 sentence = input().lower().split(" ") i = len(sentence)-1 while i>0: first_letter = sentence[i][0] i-=1 final_letter = sentence[i][-1] b = final_letter == first_letter if not b: break; print(b)
28th Jul 2022, 12:15 PM
Solo
Solo - avatar
- 1
It was a code coach it's named flowing words Thank you so much!!!
28th Jul 2022, 12:20 PM
Edo
Edo - avatar