# dogs-lists10 #Example using lambda #Dog Description List format = [,,, ] dogs = [["Mandy", 2, "F", "Chinook"], ["Harry",11,"M", "Chinook"], ["Shenanigans",8,"F", "Chinook"], ["Colorado",10,"F", "Chinook"], ["Katrina", 9, "F", "Chinook"], ["Rusty",10.5,"M", "Golden Retriever" ], ["Tanner", 16, "M", "Golden Retriever"] ] # Poor method to print list print(dogs) # Print the list & position positionId = 0 for dog in dogs: print("{} {}".format(positionId,dog)) positionId += 1 # Print males in the list print("\n - These are the male dogs") positionId = 0 for dog in dogs: if dog[2] == "M": print("{} {}".format(positionId,dog)) positionId += 1 print("\n") # Print females in the list print("\n - These are the female dogs") positionId = 0 for dog in dogs: if dog[2] == "F": print("{} {}".format(positionId,dog)) positionId += 1 print("\n") print("Sort by sex") print(sorted(dogs, key=lambda x: x[2])) print("Sort by name") print(sorted(dogs, key=lambda x: x[0])) print("Sort by age") print(sorted(dogs, key=lambda x: x[1])) print("Sort by breed") print(sorted(dogs, key=lambda x: x[3])) print("\n") print(dogs)