If you need to normalize a list of numbers in Python, then you can do the following:

## Option 1 – Using `Native Python`

 ``````1 2 3 4 5 6 7 `````` ``````list = [6,1,0,2,7,3,8,1,5] print('Original List:',list) xmin = min(list) xmax=max(list) for i, x in enumerate(list): list[i] = (x-xmin) / (xmax-xmin) print('Normalized List:',list) ``````

## Option 2 – Using `MinMaxScaler` from `sklearn`

 ``````1 2 3 4 5 6 7 `````` ``````import numpy as np from sklearn import preprocessing list = np.array([6,1,0,2,7,3,8,1,5]).reshape(-1,1) print('Original List:',list) scaler = preprocessing.MinMaxScaler() normalizedlist=scaler.fit_transform(list) print('Normalized List:',normalizedlist) ``````

You can also specify the `range` of the `MinMaxScaler()`.

 ``````1 2 3 4 5 6 7 `````` ``````import numpy as np from sklearn import preprocessing list = np.array([6,1,0,2,7,3,8,1,5]).reshape(-1,1) print('Original List:',list) scaler = preprocessing.MinMaxScaler(feature_range=(0, 3)) normalizedlist=scaler.fit_transform(list) print('Normalized List:',normalizedlist) ``````