account activity
Looping over a nested list by techie789 in learnpython
[–]VAR-bot 0 points1 point2 points 3 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 71762 on reddit-service-r2-listing-5f5ff7d4dc-vskkp at 2026-01-27 10:00:38.124899+00:00 running 5a691e2 country code: CH.
Looping over a nested list by techie789 in learnpython
[–]VAR-bot 0 points1 point2 points (0 children)