I have coded a class that stores a name string and an int ratings ("John", 6) and stored it in a list "teams = []"
class player():
def __init__(self, name, rating):
self.name = name
self.rating = rating
teams = []
teams.append(player("juanma", 6))
teams.append(player("pablo", 7))
teams.append(player("gon", 5))
teams.append(player("pep", 4))
I have then used the combinations tool from itertools and I am trying to get it to print all the possible combinations. The problem is that it is printing the memory allocation instead of the variables.
comb = combinations(teams, 2)
for i in comb:
print(i)
This is the output that I get:
(<__main__.player object at 0x7fc4999698b0>, <__main__.player object at 0x7fc499969610>)
(<__main__.player object at 0x7fc4999698b0>, <__main__.player object at 0x7fc499999e20>)
(<__main__.player object at 0x7fc4999698b0>, <__main__.player object at 0x7fc499a015e0>)
(<__main__.player object at 0x7fc499969610>, <__main__.player object at 0x7fc499999e20>)
(<__main__.player object at 0x7fc499969610>, <__main__.player object at 0x7fc499a015e0>)
(<__main__.player object at 0x7fc499999e20>, <__main__.player object at 0x7fc499a015e0>)