I would like to compare two string lists, locate the common strings and store the common strings in a new list.
For example:
my_list1=[' 4, -40., -12.\n',
' 5, -40., -15.\n',
' 6, -40., -18.\n',
' 7, -40., -21.\n',
' 8, -40., -24.\n',
' 9, -40., -27.\n',
' 14, -30., -30.\n',
' 15, -28., -30.\n']
my_list2=['49',
'50',
'51',
'10',
'53',
'54',
'55',
'56',
'57',
'58',
'59',
'60',
'6162',
'15',
'64',
'65',
'66']
What I want to do is compare each of the strings of my_list2 with the beginning of the strings in my_list1.
For example my_list1
contains '15'
from my_list2
in [ '15, -28., -30.\n']
so i want a new list which is going to save all the common strings