"Cannot Subscript a value of type '[String]' with an index of type 'String' "
<p>Swift 3.0</p>

<p>Got this error: "Cannot Subscript a value of type '[String]' with an index of type 'String' "</p>

<p>when I tried to loop through an array "pokemon" of Strings: </p>

<pre><code>for x in pokemon {

    var name: String!
    name = pokemon[x]

    poke = Pokemon(name: name, pokemonId: x)

    pokemons.append(poke)
}
</code></pre>

<p>However, it worked when I wrote: </p>

<pre><code>for x in 1..&lt;pokemon.count {

   var name: String!
    name = pokemon[x]
    poke = Pokemon(name: name, pokemonId: x)
    pokemons.append(poke)
}
</code></pre>

<p>After researching, it seems that "for x in pokemon" makes "x" not an Int, but a String (actual array elements).
Why this happens? </p>