+ 1
Anyone help me?
I wrote a code to split a string by two characters. It is not working if the characters are not unique. How do I solve this? What if I had to split the string in terms of three characters? https://code.sololearn.com/ctrpi6r6g1bs/?ref=app
8 Respostas
+ 9
Harsha S ,
a bit late, but i did a try with your code and only correct it slightly. see the file with the code and the comments:
https://code.sololearn.com/cXiQ97mXUyk5/?ref=app
+ 3
Harsha S
What about this?
https://code.sololearn.com/c9lEO4buSW1R/?ref=app
+ 3
You can split the string by k characters
https://code.sololearn.com/cuZiYnCRjE3e
+ 2
If this is what you want !?
https://code.sololearn.com/cwt96uj0C5RR/?ref=app
+ 2
Harsha S
In your code ,you are using x.index(i) which returns index of first charecter occurred index so if it have duplicates then it will always returns first occurence index. so that may the reason.
+ 2
thanks all