Новый курс! Каждый программист должен знать генеративный ИИ!
+ 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♠️👨🏿‍💻
6 ответов
+ 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
+ 7
Hood♠️👨🏿‍💻 here is maybe a close example of what you may be looking for https://sololearn.com/compiler-playground/cXtrtvDj3WWh/?ref=app
19th May 2024, 10:35 PM
BroFar
+ 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
+ 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
20th May 2024, 5:24 PM
Oma Falk
0
Guys Please sand me any simple cod
21st May 2024, 6:43 PM
Amanuel Worku
Актуальное сегодня
Python