I have a question about a simple quiz which is removing a specific key from a dictionary with function. Input must be taken from user. For example:
myDict = {'a':1,'b':2,'c':3,'d':4}
keyToRemove = ‘a’
would remove the first element from the dictionary and return the result.
I have developed such a code, but when I type 'a' it doesn't work. When I type only a it is removed. Could you help me to solve this question?
myDict = {'a':1,'b':2,'c':3,'d':4}
def key_Remover(Dict):
x = input("Please enter dictionary key to remove: ")
del Dict[x]
return Dict
key_Remover(myDict)
print(myDict)