Use range instead of traditional for loop

This should be faster and is a little easier to read. It also shows that while semantically difficult (I have left previous behaviour) it is now possible to relax len(s) restriction since when len(s) == 1, the for loop is a no-op. Depending on how you interpret s[i] <= v < s[i+1], it is either valid (but empty) or panicable.