I'm a beginner in programming and am currently taking a Python class. I'm using PyCharm, and was writing a function to merge dictionaries. I have the number of arguments set to variable, and wanted to store the number of arguments actually being passed through when the function is called as a variable to be used in a while loop. While typing it out, the __len__()
method came up, and it seemed to do exactly that. I was wondering if someone can explain how this works? I tried searching for the answer but I'm not completely sure I understand how __len__()
works, and how it worked in this case.
Thank you, Melissa
def merge_dicts(*dict):
num_of_dicts = dict.__len__()