Python Discussion Forums

There's no such thing as a stupid question. Ask. Discuss. Learn.

I would like an explanation on this problem on how the zip function works

A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B = [[3, 3, 3],
[4, 4, 4],
[5, 5, 5]]
[[col1 * col2 for (col1, col2) in zip(row1, row2)] for (row1, row2) in zip(A, B)]

Possible output

a) [0, 30, 60, 120, 160, 200, 300, 350, 400]
b) [[0, 30, 60], [120, 160, 200], [300, 350, 400]]
c) No output
d) Error

Sunil Kamat 4 months ago
  • Dinasbhai Dinasbhai

    I'm a beginner, and I don't know much about DLL's, applications, or how they're made, or how they really work. But recently I finished brainstorming an idea for my first application that's too good to pass up.

    I tried to teach myself python about a year ago, but I didn't last the first week of reading. Now that my idea is complete, I need to learn Python again, and I have that covered. All I'm asking this community is: How do I create an application like MS Word, MS Excel and others? I already researched this question and all I'm coming across is advice that isn't in Layman's terms, I can't understand what they're talking about.

    I already downloaded a GUI package called wxPython using pip. I followed a tutorial online about how to use the various widgets. But the tutorial didn't explain ALL of what each thing means, especially for a beginner like myself.

  • Whitelisted Links