+ 1
Flowing words
Can anyone help I solved it but the case number 3 still wrong why???
6 odpowiedzi
+ 4
Menna Elsayed ,
this depends on the input data (strings) test cases provided from sololearn:
> the first one has only 2 words and is meeting the requirements
> the second one has more words, but all of them are meeting the requirements.
> for all the other cases we can not see what input is used
try to rework the code as described in my last post.
i just saw that you have modified your code. now all word pairs are checked. but we have the issue, that `true` or `false` is printed repearedly after each check. it should be printed only once as the last step.
+ 2
Hi Menna Elsayed, can you please review the following and update your question. That allows us to better help you:
https://sololearn.com/compiler-playground/Wek0V1MyIR2r/?ref=app
https://sololearn.com/compiler-playground/W3uiji9X28C1/?ref=app
https://sololearn.com/compiler-playground/W0uW3Wks8UBk/?ref=app
+ 2
Menna Elsayed ,
do you try to solve the challange in the code coach?
https://www.sololearn.com/coach/87?ref=app
>> just a hint:
> the current code checks if the *last char of the first word* is equal to the *first char of the second word*.
> if this is true, `true` will be returned, but we do not check the following words.
read the task description:
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.
+ 1
def flowing_words(sentence):
sentence = sentence.split(' ')
le= len(sentence)
for i in range(len(sentence)-1) :
if sentence[i][-1] == sentence[i+1][0]:
return 'true'
else:
return 'false'
print (flowing_words (input()))
That's my code
+ 1
I understand but why just the case number 3 still wrong?
+ 1
Yeah that's right it's working now thank youuu