-1

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.

Dave Brown
  • 31
  • 4

2 Answers2

0

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.

pael
  • 81
  • 7
0

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]
Mo B.
  • 5,307
  • 3
  • 25
  • 42