Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
random tests added to C#, this solution does not pass anymore
Check this out: https://www.w3schools.com/python/python_for_loops.asp see what the example with the string
"banana"
prints.Now try this out, that's basically what you're trying to do with your code:
And see it'll fail with the same error that you get here.
in normal python it works though.
It doesn't work because it's wrong. And it won't work anywhere. Not a kata issue.
Because
i
is not a number. Please stop right now. Go read the Troubleshooting section of the docs I told you.Read this: https://docs.codewars.com/training/troubleshooting/
About your problem:
i
is a string there (a single char), you can't usetext[i]
to access a single letter of the string, neitheri+1
makes sense.Look better at what they did, so you see how to correct your code.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
That's a problem with your code and not a kata issue, again. Please, don't open issues every single time your code doesn't work if you're not sure if the problem is in the kata and not in your code. It's as the error says: string indices must be integers.
No, they shouldn't. What is
i
there? Your code being wrong is not a kata issue.text[i] == 'w' or text[i] == 's' did not work, even though it should like in normal python.
I got an error that the system said is happening in the code, but I've seen others that can do it with my way. My code:
if text[i] == '_':
error:
string indices must be integers, not 'str'
I saw other people doing this, but mine didn't work, minor issue.