There is a find function....Is there an "opposite of find" function?

406 Views Asked by At

I want to know if you can find a letter by entering the position of it so it gives you the letter back.

In other words, I want a function that is the opposite of the find function?

P.S. if myString is a string and I input the position of the letter I want the letter in that position to come back.

2

There are 2 best solutions below

0
On

You could use indexing like: (python)

myString = "dog"
myString[1] # -> "o"

Or specific method like "myString.charAt()" (Java) (comment by a_horse_with_no_name). That depends on language.

0
On

In Java & JavaScript:

myStr.charAt(index)

In C#, C, C++, Python, PHP, Ruby you use indexing with square brackets:

myStr[index]

Similarly, in F#, you write

myStr.[index]