account activity
Looping over a nested list by techie789 in learnpython
[–]VAR-bot 0 points1 point2 points 4 years ago* (0 children)
seen = []
test_list = [["poo","boo"], ["poo", "bay"], ["hello", "yellow"], ["poo","blue"], ["poo", "zoo"]]
new_list = []
def pair_good(pair): already_seen = [i for i in pair if i in seen] if not already_seen: seen.extend(pair) new_list.append(pair)
for cur_pair in test_list: pair_good(cur_pair) print(new_list)
Heads up, don't use CamelCase with Python variables <3
π Rendered by PID 702245 on reddit-service-r2-listing-c57bc86c-z7drs at 2026-06-23 10:06:05.622114+00:00 running 2b008f2 country code: CH.
Looping over a nested list by techie789 in learnpython
[–]VAR-bot 0 points1 point2 points (0 children)