Considere o código Python a seguir.
def xpto(S):
for k in range(0,len(S)):
if k%2 == 0:
yield(S[k]);
S=[1,2,3,4,5,6]
for x in xpto(S[ : : -1]):
print (x)
A execução desse código na IDLE Shell produz, na ordem e exclusivamente, os números:
6, 1
5, 3, 1
6, 4, 2
1, 3, 5
2, 4, 6