[Solved] Rename all key in dictionaries

jason Asks: Rename all key in dictionaries
I have a dictionary, with this value:

d = {'apple':0, 'banana':1, 'mango':2, 'grava':3}

I would like to rename all the key in d to 'fruit', so that the end results will be like this:

d = {'fruit':0, 'fruit':1, 'fruit':2, 'fruit':3}

So,I try the code below:

d = {"fruits" if k != '' else k:v for k,v in d.items()}

But,the result is : {'fruits': 0}

What could possibly be going wrong here? Thanks

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.