Python - Passing arguments to functions -
i sort of new python reading through pro python , had section passing variable keyword arguments function. after reading section wrote following code doesn't seem work.
def fun(**a): return a['height'] if not {} else 0
empty hash argument not guaranteed same object newly created empty hash.
try compare using a != {}
, or a['height'] if else 0
.
or without check:
return a.get('height', 0)
Comments
Post a Comment