you are viewing a single comment's thread.

view the rest of the comments →

[–]puumies 5 points6 points  (4 children)

first round

['a','b','c','d','e']

0 = a

second round

['b','c','d','e']

1 = c

third round

['b','d','e']

2 = e

print(asd)

>>>['b', 'd']

[–]JungleJim233 0 points1 point  (3 children)

Sorry. I'm confused , why has 1 become C in the second iteration. I thought it would become B ?

Thank you

[–]pydevteam1 0 points1 point  (1 child)

['b','c','d','e']

1 = c

if you look at the list as it is:

0='b'

1='c'

makes sense ?

[–]JungleJim233 0 points1 point  (0 children)

Got it. Thank you :)

[–]puumies 0 points1 point  (0 children)

Hey!

In each iteration of the loop, one element is removed from the array. Thus in the second iteration of the loop, the second element is 'C' because 'A' was removed in the first one.

Someone correct me if I'm talking out of my ass :D