0
Please figureout the problem, in this code input: 1232323 232 output: 2
6 Respuestas
+ 2
Psycho I think you copied this code from somewhere so there are some special characters added. Check this I have rewrite the code and working fine
https://code.sololearn.com/cgWFzrFGmrE3/?ref=app
+ 12
Looks like you copied and pasted the code and brought in some unwanted characters. I would copy and paste it into MS Word as plain text, then copy and paste it back into a blank new code in the Playground to get rid of them.
You may have to tidy up the spacing and indenting to get it running properly.
+ 7
Regardless of the fact that there are invalid characters in the code, there is a much simpler way to do this task.
text = 'This is not a list'
sub = 'is'
print(text.count(sub))
# or in a nice formatting:
print(f'substring: "{sub}" appears {text.count(sub)} times in "{text}"')
+ 2
David Ashton
Or copy to Notepad then directly to your destination, no need for the extra "paste as plain text" step as with MS Word.
0
I wrote this code on online compiler and paste it here . I'm using mobile phone so there is no ms word.
0
Input: abcbcbc
bcb
Output:2
Here, I'm trying to find how many times the sub string comes in the string .
1- in abcb
2 - in bcbc