python - Get subarray from bi-dimensional array in just one line -
I have a problem finding and receiving from a two-dimensional array in Python and trying the array I get it For example does not pretend to use the structure. Someone knows how to get this array in just one or a few lines of code.
Thank you.
An example is:
my_dimensional_array I need to go back
<(1, 'A'), (1, 'b'), (2, 'c') code> my_single_array_from_1 = [(1, 'a'), (1, 'b')]
You can use the my_dimensional_array to select the elements whose first value is 1 In [16]: my_dimensional_array = [[17] in [(1, 'a'), (1, 'b'), (2, 'c')] : [Item in item i_dimensional_array if item [0] == 1] outside [17]: [(1, 'a'), (1, 'b')] < / Html>
Comments
Post a Comment