[Python] Locomotive Engineer: `fix_wagon_depot` and `zip()` are confusing

The Locomotive Engineer exercise is about packing and unpacking. The exercise, on the whole, is very nice. However, the fix_wagon_depot() requires transposing a 2D list. Most solutions use zip() and many students I’ve seen in the mentoring queue are quite confused about how to solve this and, when they look at community solutions, what zip() is and how this works.

Would it make sense to rethink/remove this last function?

CC: @Meatball @BethanyG

Yes, I have mentored a few people on the exercises and what I found as well is that some students have found the last function confusing. The point of the last function is to teach the student of functions in python where you have to “unpack”. I think there could make sense to rethink the last function.

So the introduction to the exercise has a clear example of zip(). But we could maybe provide more support there.

I don’t think removing the last task helps anything, but I do think we can explain zip() better.

I am tempted to interpret these symptoms as indicating that Hints don’t work. After all, the solution is right in there.

A worthwile goal. However, zip might not be ideal for this. It

  • deals with tuples, which are unfamiliar,
  • transforms data in an unfamiliar manner, and
  • is altogether unfamiliar itself (“why ‘zip’?”).

It might work better if an already well-known function were used instead. That way the student can more easily reuse prior knowledge.

I have no suggestions to offer (yet). I can only think of print, str.join, zip, and map right now – all not ideal. Oh, and min/max.

1 Like

All good points. But this exercise is quite a ways down the concept tree.

Its prerequisites include working with lists and tuples – and the associated practice exercises for some of those concepts have solutions that employ zip().

Unfortunately, a single encounter (or a few) does not make familiar. This is not critisism of the track.

It seems that the students expressing confusion about zip during mentoring sessions have somehow avoided it in prior exercises, or have forgotten about it, or failed to notice it. Whatever the case, these students are not familiar with zip.

I’m not sure that trying to plug the holes that these students slipped through is a viable approach. Or should I say: I expect it to be not as fruitful as one would like.

The exact solution is indeed in the hints file, but it does not explain how the zip works with the 2d list of tuples. Most explanations of how zip works use the same example [(1,2,3), (‘red’,‘green’,‘blue’)] or some such.

Perhaps a link to one of the tutorials that might go in a little more depth such as the RealPython page? Or another, better one where someone can look for more depth. Google searches mostly come up with the simple example.

I like that Real Python article. Excellent suggestion. I just wish RP wasn’t so aggressive with signup and paywalling. I’ll take a look and see if there are additional articles that might help. We might also call out zip() in a Exercism note in the instructions, and make sure that the example is one that maps better to the task.

Ultimately, Matthijs and Isaac do have a point - having a concept article and/or specific concept exercise is probably the ideal solution (maybe in conjunction with some other built-in iterator-related functions) – or we include zip() as part of an iterators concept exercise. However, that’s probably not going to happen right away.

I know a band-aid is not ideal, but I also think its better than nothing. Unless we can replace the zip() with something else in that last task?