mercredi 24 juin 2020

Take the position of the indexes that meets a condiion

I have two lists,

In the first list I have all the information:

list1 = ['node1=6d', 'node2=10d', 'node3=5d']

In the second I just have the days:

list 2 = [6, 10, 5]

Is there a way to take the position from the indexes of the second one, that are <=7 ? (For example) and then print those with the same position of the list1?

Example:

Values of list2 that are <= 7:

Position 0, 2

Then print from list one those values with the position 0, 2

Output should be:

['node1=6d', 'node3=5d'] 

Aucun commentaire:

Enregistrer un commentaire