python dict.fromkeys() returns empty
- by slooow
I wrote the following function. It returns an empty dictionary when it should not. The code works on the command line without function. However I cannot see what is wrong with the function, so I have to appeal to your collective intelligence.
def enter_users_into_dict(userlist):
newusr = {}
newusr.fromkeys(userlist, 0)
return newusr
ul = ['john', 'mabel']
nd = enter_users_into_dict(ul)
print nd
It returns an empty dict {} where I would expect {'john': 0, 'mabel': 0}.
It is probably very simply but I don't see the solution.