pass
if validity_check:
num = sorted([(len(v),k) for k,v in groups.items()])
for i in num[1:]:
if i[0] < num[0][0]:
print("Warning, key "%s" has less values than "key" %s." % (i[1], num[0][1]))
After Change
if validity_check:
lens = [len(groups[k]) for k in groups.keys()]
if len(set(lens)) > 1:
raise ValueError("Warning, some keys have more/less values than others. Set validity_check=False to ignore this warning.")
return groups