So I'm given a list of tuples. Each tuple contains an integer, a string, and a boolean. I want to go through the list and find the first tuple that has a False for that boolean, do some operation with the tuple, then change the boolean to true. Here's some sample code:
def sendnext(packets):
for (number, data, sent) in packets:
if not sent:
sendsegment(number, data)
sent = True
break
Obviously, I can't just change sent to True. The list can also grow arbitrarily large, so I don't want to make a copy of it or use a list comprehension. I know I could use indexing, but that will probably reduce readability. I feel like there should be a pythonic way to do this. Any suggestions?
Thanks for your help!
sendsegmentif sent = False?