for b in a:
continue
Not sure what you expect this line to do.
What it actually does is execute a for
loop in which nothing happens. At the beginning of each iteration of a for
loop, the loop control variable (in this case b
) gets assigned the value of the next element in the iterable (in this case, a
.
In this case, the loop would iterate three times:
b = 'Ironman'
b = 'Thor'
b = 'Spiderman'
and since the interior of the loop is empty (just the continue
statement, which means "jump back to the top of the loop immediately and go to the next iteration"), nothing happens.
Now, once the loop finishes iterating, the variable b
isn't cleared or reset. The last thing assigned to it was the last element of a
, which is the string 'spiderman'
.
Did you mean to do:
for b in a:
d = []
for c in range(5):
d += random.choice(string_pool)
print("{} : ".format(b) , d)
Note how the rest of the function is inside the for
loop.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…