OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to remove items from a list while iterating?

  • Thread starter Thread starter lfaraone
  • Start date Start date
L

lfaraone

Guest
I'm iterating over a list of tuples in Python, and am attempting to remove them if they meet certain criteria.

Code:
for tup in somelist:
    if determine(tup):
         code_to_remove_tup

What should I use in place of code_to_remove_tup? I can't figure out how to remove the item in this fashion.
<p>I'm iterating over a list of tuples in Python, and am attempting to remove them if they meet certain criteria. </p>

<pre><code>for tup in somelist:
if determine(tup):
code_to_remove_tup
</code></pre>

<p>What should I use in place of <code>code_to_remove_tup</code>? I can't figure out how to remove the item in this fashion.</p>
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top