0
My_list = ['ABCD:123H', 'ABEF:456J']
for pf in My_list:
   if pf in ['ALL', 'CD', 'AB']:
      print('yes')

The above code is not working but the below code is working

My_list = ['ABCD:123H', 'ABEF:456J']
for pf in My_list:
   if pf in ['ALL', 'CD', 'ABCD:123H']:
      print('yes')

How to match when a part of the element is present in elements of a list? example: 'AB' is part of the element 'ABCD:123H'. So it should print YES when iterating through the list of elements.

Tomerikoo
  • 15,737
  • 15
  • 35
  • 52

0 Answers0