-1

I have a list of arrays:

[array([1,2,3,4],dtype=float32), array([5,6,7,8],dtype=float32)]

How can I reverse this list so that it looks like:

[array([5,6,7,8],dtype=float32), array([1,2,3,4],dtype=float32)]

this?

Joo Sohn
  • 25
  • 1
  • 6

2 Answers2

1

Just use negative step:

from numpy import array

a = [array([1,2,3,4],dtype='float32'), array([5,6,7,8],dtype='float32')]
a[::-1]
zipa
  • 27,316
  • 6
  • 40
  • 58
0

You can reach with using this:

li = li[::-1]

That way, you assign li with the reversed list of lists.

omri_saadon
  • 10,193
  • 7
  • 33
  • 58