I'm just starting with Python, and I can't figure out how to group tuples. For instance, I have tuple1=("A", "B", "C") and tuple2=("1","2","3"). I want to combine these into a list, grouped ...
tuple1=("A", "B", "C")
tuple2=("1","2","3")
I have a list of (label, count) tuples like this:
[('grape', 100), ('grape', 3), ('apple', 15), ('apple', 10), ('apple', 4), ('banana', 3)]
Given a list
old_list = [obj_1, obj_2, obj_3, ...]
new_list = [[obj_1, obj_2], [obj_3], ...]
obj_1.some_attr == obj_2.some_attr
for
if
Given:
x = '1 (2,3), 4 (5)'
y = [(1,2),(1,3),(4,5)] ?