Passengers may not only have a single sibling, spouse, parent, or child. They can have many. For instance, the Carter family, where the father is Mr. William Ernest Carter, consists of the parental couple and two children.

Before we see what happens, let’s further structure our code. We define the prepare_group function. It takes a PassengerId and returns the corresponding passenger and a list of potential relatives.

Get hands-on with 1400+ tech skills courses.