I have a dictionary as seen below:
Dict = {' Chicago ': 4, ' Washington ': 9, ' LA ': 26, ' Boston ': 12, ' Seattle ': 2}
I want to edit the key of each entry, but not the values. The keys you can see have a string which includes whitespace at the start and end: ' Chicago ', ' Washington ', ' LA '.
I want to group through and strip the white space from the keys. Leaving me with the following dictionary.
Dict = {'Chicago': 4, 'Washington': 9, 'LA': 26, 'Boston': 12, 'Seattle': 2}
How would I do this? Maybe using the replace(" ", "") method or the strip()?
When trying the strip method I get the error:
AttributeError: 'int' object has no attribute 'strip'