Python Forum
passing dictionary to the function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
passing dictionary to the function
#2
One way
dict1 = {
    'key1': 1,
    'key2': 2
}

dict2 = {
    'key': 1,
    'key4': 4
}

def myfunction (arg1, arg2):
    if arg1 == arg2:
        return 'Dicts are equal'
    return 'Dicts do not match'

print(myfunction(dict1, dict2))
You may also want to look at deepdiff from pypi
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
passing dictionary to the function - by mark588 - Dec-19-2022, 06:20 PM
RE: passing dictionary to the function - by menator01 - Dec-19-2022, 06:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Passing flags to python script, through a function xbit 4 4,121 Apr-20-2021, 06:32 AM
Last Post: ndc85430
  Writing a lambda function that sorts dictionary GJG 1 2,070 Mar-09-2021, 06:44 PM
Last Post: buran
  Using Dictionary to Test Evenness of Distribution Generated by Randint Function new_coder_231013 6 3,438 Feb-23-2021, 01:29 PM
Last Post: new_coder_231013
  Passing argument from top-level function to embedded function JaneTan 2 2,327 Oct-15-2020, 03:50 PM
Last Post: deanhystad
  passing variable to function Rejoice 4 2,966 Sep-11-2020, 03:27 AM
Last Post: Pleiades
  Mathplotlib - passing reference to axs to function qmfoam 5 3,053 Aug-17-2020, 09:02 PM
Last Post: qmfoam
  Passing variable to another function JonnyDriller 10 3,986 Feb-05-2020, 03:46 AM
Last Post: JonnyDriller
  Passing Values of Dictionaries to Function & Unable to Access Them firebird 3 2,663 Aug-03-2019, 10:25 PM
Last Post: firebird
  How to pass a dictionary as an argument inside setup function of unittest nilaybnrj 1 3,271 May-11-2019, 03:18 AM
Last Post: keames
  Passing a local variable outside of a function malonn 8 4,079 Apr-15-2019, 01:50 AM
Last Post: malonn

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020