I have values in two different lists:
list1 = [
"1003_0123_20200821091044_ion_fri_jl.dat",
"8005_0086_20200821090605_ion_fri_jl.dat",
"1003_0123_20200821091999_ion_fri_jl.dat",
]
list2 = [
"IMM CCA CADD USD GAAP_202103311352_20200821091999_FRI",
"ICM CCA CADD USD GAAP_202103311352_20200821090605_FRI",
"CCA CTAD USD GAAPA_202103311352_20200821091044_FRI",
]
I want to pair the values that have the same substring obtained by str.split('_')[2]. For instance, the first element in list1 has the substring 20200821091044, which matches the third element in list2. Then I want to have the matched values like this:
[
(
"1003_0123_20200821091044_ion_fri_jl.dat",
"CCA CTAD USD GAAPA_202103311352_20200821091044_FRI",
),
(
"8005_0086_20200821090605_ion_fri_jl.dat",
"ICM CCA CADD USD GAAP_202103311352_20200821090605_FRI",
),
(
"1003_0123_20200821091999_ion_fri_jl.dat",
"IMM CCA CADD USD GAAP_202103311352_20200821091999_FRI",
),
]
or in a dictionary format.