I’m not sure I’m using this forum right. But i was sent here from the github issue.
I’ve found out that types in the docstring of the fix_wagon_depot function in the Locomotive Engineer exercise are misleading.
Instructions says:
Implement a function called
fix_wagon_depot()
that accepts alist
of three items. Eachlist
item is a sublist (or “row”) that contains threetuples
. Eachtuple
is a(<wagon ID>, <wagon color>)
pair.Your function should return a
list
with the three “row”lists
reordered to have the wagons swapped into their correct positions.
>>> fix_wagon_depot([
[(2, "red"), (4, "red"),(8, "red")],
[(5, "blue"),(9, "blue"),(13,"blue")],
[(3, "orange"),(7, "orange"), (11, "orange")],
])
[
[(2, "red"),(5, "blue"),(3, "orange")],
[(4, "red"),(9, "blue"),(7, "orange")],
[(8, "red"),(13,"blue"),(11, "orange")]
]
So the types of a parameter and the return value of the function should both be list[list[tuple]]
or even list[list[tuple[int, str]]]
. But predefined code contains wrong types in the docstring:
def fix_wagon_depot(wagons_rows):
"""Fix the list of rows of wagons.
:param wagons_rows: list[tuple] - the list of rows of wagons.
:return: list[tuple] - list of rows of wagons.
"""
pass
I suggest changing it to:
def fix_wagon_depot(wagons_rows):
"""Fix the list of rows of wagons.
:param wagons_rows: list[list[tuple]] - the list of rows of wagons.
:return: list[list[tuple]] - list of rows of wagons.
"""
pass