mercredi 29 janvier 2020

unable to append using if statement

I have three lists. I would like to append the list object onto 'filtered' list if the object contains "HP" or "LP." The output places all items of filenames onto 'filtered' instead. Unsure why this is occuring. Your insight would be appreciated!

filenames = ['HP PLEAS 56s Jazz.wav', 'HP PLEAS 57s groupLaughing.wav', 'HP 
PLEAS 57s Guitar_2.wav', 'PLEAS 56s Jazz.wav']
filtered = []
original = []

for x in filenames:
    if "LP" or "HP" in x:
        filtered.append(x)
    else:
        original.append(x)

Aucun commentaire:

Enregistrer un commentaire