I'm a beginner at Python. I couldn't find what I wanted even if I searched it. I ask for your help me.
List1 = [{'id':1}, {'id':2}, {'id':3 }, {'id':4}]
List2 = [{'id':1}, {'id':4}]
If you compare the value of list1 with the value of list2 in order and get the same value, You want to organize a specific function to run.
python list compare
The dictionaries in each list have the same key. This means that you only need to use the value.
>>> List1 = [{'id':1}, {'id':2}, {'id':3 }, {'id':4}]
>>> List2 = [{'id':1}, {'id':4}]
>>> intersection_items = set([item['id'] for item in List1]) & set([item['id'] for item in List2]) # Find the intersection (equal value) in the dictionary of the two lists.
>>> list(map(lambdai:i*2, intersection_items)) # Apply a function that multiplies the items of the intersection by 2.
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
581 PHP ssh2_scp_send fails to send files as intended
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.