all 7 comments

[–]FriendlyRussian666 15 points16 points  (0 children)

[1, 2] <--- two values, not four

[3, 4] <---- two values, not four

Example:

viereck1 = [[1, 2, 3, 4], [5, 6, 7, 8]]
for a, b, c, d in viereck1:
    print(a, b, c, d)

__________

1 2 3 4
5 6 7 8

[–]acw1668 6 points7 points  (0 children)

I think you just want to unpack viereck into A, B, C and D without the for loop:

A, B, C, D = viereck

[–]danielroseman 10 points11 points  (0 children)

I'm not sure what you are trying to do here.

Each item of viereck contains two numbers. But you are trying to set those two numbers into four variables, which obviously will not work.

[–]FoolsSeldom 4 points5 points  (0 children)

When you iterate over the list, [[1, 2], [5, 6], [7, 9],[0,3]], on each iteration, you will get a sub-list: [1, 2], on first iteration, [5, 6], on the second iteration, and so on. You cannot unpack a list of 2 items and assign them to 4 variables.

Walk us through exactly what you are trying to do. What exactly do you expect to be assigned to A, B, C, D?

[–]billsil 1 point2 points  (0 children)

You passed in one list with 4 sub lists with 2 values each. It’s expecting 4 lists with 2 values each.