mercredi 23 juin 2021

Grab last iteration of a specific list in Python -- and only last specific item

How do I grab that last iteration of a specific item in a python list that matches my if statement?

for example:

my_list = ["passed1", "passed2", "passed3", "vetoed"]
my_other_list = ["passed4", "passed5", "passed6", "vetoed"]

combo_list = []
combo_list.append(my_list)
combo_list.append(my_other_list)

desired_output_list = []

How do I grab the final iteration of "passed" and ONLY the final iteration of passed?

for x in combo_list:
    ###Grab passed3 and passed6 and append to desired_output_list

Aucun commentaire:

Enregistrer un commentaire