Jan-03-2017, 06:34 AM
Hi all,
I'm having trouble with calling a function which takes a dictionary as argument
for example If I have
2. in the function(which takes this dictionary as argument), if the length of this dictionary is 0, return the original dictionary(an empty dictionary), if the length is larger than zero, add one element to the dictionary, and return the updated version of the dictionary.
so if I want to call this function and get the returned dictionary,
function(**dic) doesn't work, what should I do instead? or what I did wrong
I'm having trouble with calling a function which takes a dictionary as argument
for example If I have
dic = {3:0.2, 4:0.5, 5:0.1, 6:0.8, 7:0.34} def function(**dic): if len(dic) == 0: return dic elif len(dic)>0: dic [100] = 0.1 return dic function(**dic)1. basically I first have a dictionary defined,
2. in the function(which takes this dictionary as argument), if the length of this dictionary is 0, return the original dictionary(an empty dictionary), if the length is larger than zero, add one element to the dictionary, and return the updated version of the dictionary.
so if I want to call this function and get the returned dictionary,
function(**dic) doesn't work, what should I do instead? or what I did wrong