Below code does not work, data is a dictionary & I was wondering how to pass it to function
def my_function(x={}):
for i , j in x:
print (i)
print (j)
data = {'a':1, 'b': 2, 'c': 3}
my_function(**data)
The below code should work for you:
def my_function(x={}):
for i, j in x.iteritems():
print (i)
print (j)
data = {'a':1, 'b': 2, 'c': 3}
my_function(data)
Explanation
dict.iteritems (in Python 2.x) or dict.items (in Python 3).** operator.
my_function(data)