i is the item from teams. It's not an index. (Hint: when debugging this kind of problem, stick a print(i) inside the loop to make sure it's what you think it is.)
Now even after taking that into consideration, and rewriting your code to use a real index via either enumerate() or range(), you may still have some trouble, because you're removing items from the list while you're iterating over it. This will cause you to skip over some of them, because for is using an index internally and adds 1 to it each time through the loop. So deleting the current item moves the next-higher item into its place, then the index is incremented and the next one after that is now considered.
The most straightforward solution to that problem is to create a new list that contains only the elements you want to keep:
newteams = []
for team in teams:
if not (newteams and newteams[-1] == team):
newteams.append(team)
Basically, this will add a new item to newteams only if 1) newteams is empty or 2) the last item of newteams doesn't match the current team. Result: runs of duplicates of any length are reduced to a single item. If this needs to modify the list teams in place, then use a slice assignment afterward:
teams[:] = newteams
Another approach is to use a set to keep track of items we've already seen. (We use a set because it's fast to check to see whether something is in it.) Then we can simply omit the items we've already seen anywhere in the list -- with the previous approach, the list would need to be sorted for that to happen.
seen = set()
newteams = []
for team in teams:
if team not in seen:
newteams.append(team)
else:
seen.add(team)
With a little abuse of Python, one can condense this to the following (though you probably shouldn't, especially as a newcomer to the language):
seen = set()
teams[:] = (seen.add(team) or team for team in teams if team not in seen)
Of course if you don't care about the order (or are willing to sort the list afterward) @RMcG`s solution of converting to a set and back is even simpler.
teamsis a list of strings, I don't thinkiswill necessarily do what you want either. Use==to test strings for equality;istests identity.