+ 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
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.
+ 7
Hoodâ ïžđšđżâđ» here is maybe a close example of what you may be looking for
https://sololearn.com/compiler-playground/cXtrtvDj3WWh/?ref=app
+ 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.
+ 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
0
Guys Please sand
me any simple cod