Hello Friends,
I have a small function in python. When i pass a dictionary(named 'hand') to the function and return it, the contents of the dictionary get swapped.
def updateHand(hand, word):
return hand
print updateHand({'a':1, 'q':1, 'l':2, 'm':1, 'u':1, 'i':1},"quail")
OUTPUT:
{'a': 1, 'i': 1, 'm': 1, 'l': 2, 'q': 1, 'u': 1} - Dictionary contents swapped
You can see the difference in the output.
Has any one experienced this before?
How can i avoid mutation of the dictionary contents while passing to a function.
Thanks,
Rahul