Below is my code.
test_str = '1:20,3:4,5:30'
res = []
for sub in test_str.split(','):
if ':' in sub:
res.append(map(str.strip, sub.split(':', 1)))
res = dict(res)
print(res) // result {'1': '20', '3': '4', '5': '30'}
This gives me dict
but with type str
but I want to be type of int. How should I convert it?
Any leads, please?