I have created this dictionary from a file. It has a key with a list of values. The elements in the list are all strings. I want to convert the elements at the indices 1 through 3 to integers.
Here is one key:value that I have in my dictionary.
{'Youngstown': ['OH', '4110', '8065', '115436'].....}
I want to leave the 'OH' as a string and convert all the other elements to integers.
Like this:
{'Youngstown': ['OH', 4110, 8065, 115436].....}
This is the code that I have so far.
d3 = {}
for k,v in d2.items():
for i in v:
for v in range(1,3):
d3[k] = int(v)
print(d3)
However, this just gives the following result:
{'Youngstown': 2, ...}
This is in python.