'Assign probabilistic weight to a list of list

I have a list of list of 40,000 points. It is created by the following code

x_dim = 10
y_dim = 10
grid_spacing = 0.025
user_grid = []
z_grid = 1
for x_grid in np.arange(0, x_dim, grid_spacing):
    for y_grid in np.arange(0, y_dim, grid_spacing):
        # User grid has length = num of grid points and each point contains 3 coordinates
        user_grid.append([x_grid, y_grid, z_grid])

I want to assign a weighted value between 0 to 1 to these points. I am able to access the first N points. Say first 200 points form my left edge on a 2D surface. But how do I access the last N or the topmost or the bottom-most point?

Initially with the help of enumerating and indexing it was easy to assign the weight 1 to all.

np.ones(len(user_grid))

But how can I do it selectively?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source