Beginner question: I am trying to evaluate whether two values in a row match.
a = ['sl','sl','cr','cl']
This is my current code:
while (j+1) < len(a):
if a[j] == a[j+1]:
num = num + 1
else:
num = num
However, when I do it this way it doesn't count the first value in the list - this is due to (j+1), however, if I remove it, get an error telling me my index is out of range - any advice would be appreciated.