python to check if list of int contains in data with ~

I have a list and item like below and want to check if any int in the item contains value ~1~20448~3~22901~12214~27681~9920408~20013~19957~19993~ ~ ~ ~ ~ ~ we should get 1 else 0.

       my_list = ['4587','9920408','9920316']
       flag=0
       value=""
       for item in my_list:
            if '~1~20448~3~22901~12214~27681~9920408~20013~19957~19993~ ~ ~ ~ ~ ~' in item and flag==0:
                 value == 1
            else:    
                 value == 0

Here in the list we have 9920408 and we have that value in the item and the output should be 1 .
But i am getting the below value.

      False
      False
      False

Could you please advise on this. Appreciate your support.

>Solution :

Use the tools Python provides:

my_list = ['4587','9920408','9920316']
st = '~1~20448~3~22901~12214~27681~9920408~20013~19957~19993~ ~ ~ ~ ~ ~'
if any( m in st for m in my_list ):
    print( "One of them was found." )

Leave a Reply