Show me three different ways of fetching every third item in the list

Technology CommunityCategory: PythonShow me three different ways of fetching every third item in the list
VietMX Staff asked 3 years ago
[x for i, x in enumerate(thelist) if i%3 == 0]

for i, x in enumerate(thelist):
    if i % 3: continue
    yield x

a = 0
for x in thelist:
    if a%3: continue
    yield x
    a += 1