I've got a simple function:
def foo(inp):
i = 0
while (i < len(inp)):
yield {i,inp[i]}
i = i+1
for x in foo(("a", "b", "c")):
print(x)
which I expect to print
{0, 'a'}
{1, 'b'}
{2, 'c'}
but it sometimes prints
{0, 'a'}
{1, 'b'}
{'c', 2}
Why are the last tuple's members swapped?
To make it stranger, adding "d" to the input list, I see three different outputs. Either all outputs are in order, I get only {'d',3)
swapped, or I get both {'c',2)
and {'d',3)
swapped
sys.version: 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)]