Is there a way for me to access only certain elements in a 2D array, for example the vertical elements only or the first elements in a set of ordered pairs, in Python?

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

Is there a way for me to access only certain elements in a 2D array, for example the vertical elements only or the first elements in a set of ordered pairs, in Python?

Computer Science
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

2D arrays? you mean lists of lists, or python's array module, or do you mean numpy's arrays?
lists of lists: A = [[1,0,0], [0,1,0], [0,0,1]] if you only want to get out the 'columns' then you can transpose it using list comprehensions.
or you can simply loop: col2 = [] for row in A: col2.append(row[1]) # gets out the elements in the 2nd "column"

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

list comprehensions: col2 = [row[1] for row in A]
sets of ordered pairs? you mean Python's native set() ?

Not the answer you are looking for?

Search for more explanations.

Ask your own question