I'm a new Python user struggling with this task. I have Python code that generates 2 lists in the following format:
list1 = [{
"City": "Paris",
"Food": "Croissant",
"Price": 10
},
{
"City": "Prague",
"Food": "Sausage",
"Price": 15
}]
list2 = [{
"City": "Paris",
"Food": "Croissant",
"Price": 10
},
{
"City": "Prague",
"Food": "Sausage",
"Price": 15
},
{
"City": "Berlin",
"Food": "Beer",
"Price": 5
}]
I would like to compare list2 to list1 to identify the differences and then spit out a new list containing just the new items. In this example, the new final list would just be:
list3 = [{
"City": "Berlin",
"Food": "Beer",
"Price": 5
}]
I tried using sets but that doesn't seem to work on these lists.