Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to replace single string in all dictionary keys in python

sample_dictionary={'Ballaji 05': 'QA', 'Priya 06': 'QA tech'}
sample_dictionary={key.replace(" ",""):value
                   for key,value in sample_dictionary.items()
                   }
print(sample_dictionary)
>>{'Ballaji05': 'QA', 'Priya06': 'QA tech'}
 
PREVIOUS NEXT
Tagged: #replace #single #string #dictionary #keys #python
ADD COMMENT
Topic
Name
9+1 =