-3

a: {'A': '120', 'B': '100', 'C': '100', 'D': '100'}

how do I make it become this:

b: {'A': 120, 'B': 100, 'C': 100, 'D': 100}

iliya
  • 514
  • 6
  • 19
Lulu
  • 13
  • 3

1 Answers1

0

Try this

a = {'A': '120', 'B': '100', 'C': '100', 'D': '100'}

for x in a.keys():
  a[x] = int(a[x])

or this

a = {'A': '120', 'B': '100', 'C': '100', 'D': '100'}
a = {k : int(v) for k, v in a.items()}
devios
  • 225
  • 2
  • 13
  • ahh this is what i need, i checked the one they recommended but it's inside a nest and i am not really sure how to do it. thanks alot! – Lulu Feb 28 '21 at 17:05
  • @Lulu You're welcome! Can you mark my answer as correct? I'd appreciate it a lot – devios Feb 28 '21 at 17:18