lundi 22 juin 2020

Delete Special Character Elements, Single Character elements from list

I have the below list of strings:

price_list = ['0W2', '1', '1', '1626.9', '1.4', '0.09', '20/06', '1603.4', '23.5', '1.4', '4:29', '55']

I need to delete every occurrence of the below from my list:

  1. Single digit numbers
  2. Special characters such as '/' and ":"
  3. Alphabets

My final price_list should be: price_list = ['1626.9', '1.4', '0.09', '1603.4', '23.5', '1.4', '55']

I tried several ways but they only removed the first occurrence.

Aucun commentaire:

Enregistrer un commentaire