+ 1
Get indexes of specific items
Hello, I have worked in the 2D map task. I have used python. In this task I have to find out the index of the char P in a string e.g XPXPX . It can be two P in this string. Does anyone know an smart solution? https://code.sololearn.com/cVE6HoZq2akp/?ref=app
4 odpowiedzi
+ 4
The while loop will be better, because you want to search for the matching items only.
+ 3
You can take a loop and searching for the first index and than begin the next time with index +1 by the search.
+ 1
I used a for loop. But in my opinion it is not the best solution. I fought there is a smarter way with re or list functions
0
Why not go with a for loop or recursion.