for i in 0...A.count-1 { <== this way will not work with strings if A[i] > 0 {ct += 1} if A[i] < 0 {ct -= 1} } for i in 0.. 0 {ct += 1} if A[i] < 0 {ct -= 1} } for i in A.indices { <== this way totally works with strings if A[i] > 0 {ct += 1} if A[i] < 0 {ct -= 1} }