Mar 27, 2022
For removing items while iterating a list, the pythonic code is:
for x in mynumbers:
if x % 3 == 0:
mynumbers.remove(x)
If you're using len() in Python, you're probably doing it wrong.
For removing items while iterating a list, the pythonic code is:
for x in mynumbers:
if x % 3 == 0:
mynumbers.remove(x)
If you're using len() in Python, you're probably doing it wrong.
C.D. Reimer makes topical videos about comic cons, pop culture, Silicon Valley and technology on YouTube. https://www.youtube.com/cdreimer