I have two Class Variables in Python, e.g. Australians and Americans, they have the same attributes, but are seperate so I can differentiate between the two. I combine them into an array to sort them according age. Now I wish to display them as shown below, but I am struggling to find a way to do it. I am quite new to Python scripting and still learning.
class Aus(object):
def __init__(self, Name, Age, Height):
self.Name = Name
self.Age = Age
self.Height = Height
class US(object):
def __init__(self, Name, Age, Height):
self.Name = Name
self.Age = Age
self.Height = Height
John = Aus("John", 22, 153)
Steve = Aus("Steve", 15, 180)
Henry = PC("Henry", 20, 192)
Tim = PC("Tim", 85, 160)
Aussies = [John, Steve, Henry, Tim]
Mary = US("Mary", 21, 178)
Sue = US("Sue", 80, 159)
Americans = [Mary, Sue]
Total = Aussies + Americans
Total.sort(key=lambda x: x.Age, reverse=True)
I wish for the out put to be something like this
Tim -> 85 Years/160 cm
Sue -> 80 Years/159 cm
John -> 22 Years/153 cm
Mary -> 21 Years/178 cm
etc.
Is there a way to achieve this?