Get count of tuples in list regardless of elements orders
问题 I have a list of tuples that looks something like this: my_list = [(1,12),(12,1),(12,1),(20,15),(7,8),(15,20)] I want to get a count of the number combinations regardless of the order. For example, if it were to be simply printed, I'd like the output to be: 1,12 = 3 20,15 = 2 7,8 = 1 Basically, I have a list of connections but the direction doesn't matter, so 1 to 12 is the same as 12 to 1. I have been working on this for a while and can't come up with a clean solution. Everything I've come