+ 2

3 consecutive words

Can someone help me solve this please ? I have to write the code so it check if a string have 3 consecutive words def checkio(text: str): ... Exemple assert checkio("Hello World hello") == True assert checkio("He is 123 man") == False assert checkio("1 2 3 4") == False assert checkio("bla bla bla") == True

19th May 2024, 9:46 PM
Hoodâ™ ïžđŸ‘šđŸżâ€đŸ’»
Hoodâ™ ïžđŸ‘šđŸżâ€đŸ’» - avatar
6 Respostas
+ 8
Toni Isotalo , it is not seen as very helpful when we are going to post a ready-made code, as long as the op has not shown his attempt here. it is more helpful to give hints and tips, so that the op has a chance to find a solution by himself.
20th May 2024, 5:41 AM
Lothar
Lothar - avatar
19th May 2024, 10:35 PM
BroFar
BroFar - avatar
+ 7
Hoodâ™ ïžđŸ‘šđŸżâ€đŸ’» , i have some doubts about your last sample in the code: checkio("bla bla bla bla") == True if we are looking for *3 consecutive words* the result should be *False* since there are 4 words in the string.
20th May 2024, 5:43 AM
Lothar
Lothar - avatar
+ 4
words = text.split(" ") w = None num = 1 for a in words: if(a == w): num = num + 1 else: num = 1 w = a if(num == 3): return True return False Untested and written while on bed on my phone. But I hope you get the idea
19th May 2024, 10:24 PM
Toni Isotalo
Toni Isotalo - avatar
0
Guys Please sand me any simple cod
21st May 2024, 6:43 PM
Amanuel Worku
Amanuel Worku - avatar