I'm trying to compare every number out of this list with the 1 infront of it and the 1 after it.
For example: I got a list participants = ["A:1", "B:6", "C:5", "D:4", "E:7", "F:3", "G:10", "H:2"]
Now I wanna compare the number of B:6 to A:1 and C:5, but I have no idea how since that A,B and C are still in the way and I need to keep them for later.
You can use
Let's name your list
for previous, current, next in zip(l[:-2], l[1:-1],l[2:]): nums = [int(x.split(':')) for x in [previous, current, next]] # now do your comparison...