lundi 23 avril 2018

If statement changing itself [duplicate]

This question already has an answer here:

I'm new to Python and I have this code which looks through a list of lists and it changes the values to either 0, 1 or 2 using an if statement. However, it's not changing anything at all. Here's what it looks like:

distance_list = np.array(distances)
    for lists in distance_list:
        for i in lists:
            if i < short:
                i = 0
            elif i > short and i < max_drive:
                i = 1
            elif i > max_drive: 
                i = 2

Since it seems to be quite simple, I don't understand why it isn't working, it just returns the same list from the beginning.

Aucun commentaire:

Enregistrer un commentaire