Find a Letter in a String (Solution)
So the task talked about writing a program, which usually is an indicator that you should use a script for it. So again, I’ve opened up a new script and saved it as
finder.py, and then put in two, like, short notes.
So that works with
x, but I don’t think that’s great. If it will always look for
x, it’s maybe a little boring. So instead, I’m going to change this to allow the user to also input what character to search for.
Let’s run that again. Enter text, so now I can say
Samantha again and search for
a, and then you can see that it finds it at the index position
1, so at the second position, which is the index position one.
Become a Member to join the conversation.