I’m encountering a problem, I’ve been trying for days but without getting any results, I would like to compare 2 dictionaries, in one dictionary there are "Pre match" football matches and in the second dictionary there are "Live" football matches.
I would like to compare them with each other and if there are no pre-match games live you must print them, now I will show the code better
EXAMPLE 1
`import json
pre = [{
"Sport": "Calcio",
"Championship": "Italia - Serie A",
"Home": "Genoa",
"Away": "Inter",
"Match Full": "Genoa v Inter",
"URL": "https://www.bet365.it/#/AC/B1/C1/D8/E158355896/F3/I0/",
"Start Data": "19 Lug",
"Start Time": "21:30"
},
{
"Sport": "Calcio",
"Championship": "Italia - Serie A",
"Home": "Parma",
"Away": "Fiorentina",
"Match Full": "Parma v Fiorentina",
"URL": "https://www.bet365.it/#/AC/B1/C1/D8/E158355904/F3/I0/",
"Start Data": "17 Ago",
"Start Time": "18:30"
}]
live = [{
"Sport": "Calcio",
"Championship": "Myanmar - Lega Nazionale",
"Home": "Dagon Star United FC",
"Away": "Ispe FC",
"Match Full": "Dagon Star United FC v Ispe FC"
},
{
"Sport": "Calcio",
"Championship": "Italia - Serie A",
"Home": "Genoa",
"Away": "Inter",
"Match Full": "Genoa v Inter"
}]
check = [[x for x in pre if x['Match Full'] != i['Match Full']] for i in live]
print(check)`
I am not receiving the desired result, I also tried the following code, without receiving the right result
EXAMPLE 2
`import json
pre = [{
"Sport": "Calcio",
"Championship": "Italia - Serie A",
"Home": "Genoa",
"Away": "Inter",
"Match Full": "Genoa v Inter",
"URL": "https://www.bet365.it/#/AC/B1/C1/D8/E158355896/F3/I0/",
"Start Data": "19 Lug",
"Start Time": "21:30"
},
{
"Sport": "Calcio",
"Championship": "Italia - Serie A",
"Home": "Parma",
"Away": "Fiorentina",
"Match Full": "Parma v Fiorentina",
"URL": "https://www.bet365.it/#/AC/B1/C1/D8/E158355904/F3/I0/",
"Start Data": "17 Ago",
"Start Time": "18:30"
}]
live = [{
"Sport": "Calcio",
"Championship": "Myanmar - Lega Nazionale",
"Home": "Dagon Star United FC",
"Away": "Ispe FC",
"Match Full": "Dagon Star United FC v Ispe FC"
},
{
"Sport": "Calcio",
"Championship": "Italia - Serie A",
"Home": "Genoa",
"Away": "Inter",
"Match Full": "Genoa v Inter"
}]
for x in pre:
for i in live:
if x['Match Full'] != i['Match Full']:
print(x['Match Full'])`
What I’m trying to get is only the missing pre-match in the "live" dict, in this case it should only print "Parma v Fiorentina" as it is missing in the dictionary
Any solution will be appreciated, thank you in advance.
print(x[‘Match Full’])
missing matches
2
Answers
this should do