Reputation: 33
[[391.88096195], [386.44174122], [378.13177006], [368.87926224]]
My output is the above array of arrays, and I want to round it like:
[[391.88], [386.44], [378.13], [368.87]]
Upvotes: 1
Views: 271
Reputation: 6288
You can use the list comprehension syntax:
>>> arr = [[391.88096195], [386.44174122], [378.13177006], [368.87926224]]
>>> arr = [[round(xx,2) for xx in aa] for aa in arr]
[[391.88], [386.44], [378.13], [368.87]]
Upvotes: 1