How to access the next element in for loop in current index/iteration?
python
Solution
You can access any member of the list if you iterate by index number of the array vice the actual element:
for i in range(len(vocab_list)-1):
for j in range(len(sentence)-1):
if(vocab_list[i]==sentence[j] and vocab_list[i+1]==sentence[j+1]):
print "match"
Problem
I'm barely learning python and trying to write some code, but running in some issues trying to access the next element in the list. Here is part of my code: ``` for word2 in vocab_list: index2 = 0 for elem in sentence2: if (elem == word2 and nextElem == nextWord2) do something index2 += 1 ``` The issue is in the `nextElem` and `nextWord2`, how do I access them given that I'm in the current iteration?