Zip() with a list of lists and a second list

https://www.codecademy.com/paths/analyze-data-with-python/tracks/ida-2-introduction-to-python/modules/ida-2-3-python-lists/lessons/create-python-list/exercises/zip

If I have a list of lists like this:

mash_staff = [[“Potter”, “Colonel”], [“Klinger”, “Corporal”], [“Houlihan”, “Major”], [“Hunnicutt”, “Captain”]]

and a second list

mash_forenames = [“Sherman”, “Maxwell”, “Margaret”, “BJ”]

Will zipping the two together give me three values per list?

You can try it? That is the easiest way to find out.

looping over mash_staff will give you one element (a list with two elements), so you will still need to unpack that

1 Like