0

Why this output?

Instead of popping 1 it is popping 4? https://code.sololearn.com/cmDt0oDeL7s4/?ref=app

1st Nov 2020, 11:49 AM
@viral (◠‿◕)
@viral (◠‿◕) - avatar
3 Respuestas
+ 6
When you pop the first element in your list, all the elements shift up one place, so the element in second place of original list is now in first place. Your loop pops the first element, then the second element (of the new list), then the third element (of the even newer list). Consequently, Your first element is removed first of all, then your third element, and lastly your fifth. To see this is action, simply put your print statement inside your for loop, and see how it looks after each step.
1st Nov 2020, 11:57 AM
Russ
Russ - avatar
+ 3
Link your codebits first.
1st Nov 2020, 11:51 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 2
Show your code here
1st Nov 2020, 11:50 AM
🤴🌹Cute Princess 🌹💐
🤴🌹Cute Princess  🌹💐 - avatar