I have the following list of values:
value_list=[2.5655665, 3.151498745, 3.1, 0.9999999999]
I need to update this list keeping only to the second decimal place. I would like the result to be:
print(value_list)
[2.56, 3.15, 3.1, 0.99]
I tried to keep only to the second decimal place using the round() method passing parameter 2. As follows:
value_list.round(2)
But, the error message appears:
AttributeError: 'list' object has no attribute 'round'
I made an attempt by transforming the value_list to the array type, like this:
import numpy as np
value_list = np.array(value_list).round(2)
This way it works, but it returns an array and I needed the return to be of type list. How can I return a list with only up to the second decimal place?