171k views
2 votes
What are the valid indexes for the string ‘new york'?

User TheGeeky
by
8.2k points

1 Answer

6 votes
Most programming languages index strings in a zero-based way. This means the 'n' has index 0, and the 'k', has index 7.

So valid indexes are from 0 to (and including) 7.

VBScript would refer to the 'n' as index 1, so always check if your environment is 0-based or 1-based.
User Eric Huang
by
8.1k points