Explanation needed for Practice Problem #12


Why do we need to convert it into an integer?

Hi Saurav,

Welcome to the Community!

Next time, please, share the mission screen.

Anyway, it seems that prices are of string type, so they need to be converted into integer for further calculation. To understand the difference, try to run:

print(type('3'))
print(type(int('3')))

Hi @sauravsaurav0 and welcome to the community!

Can you please provide a link to the practice problem you’re working on? You may want to read this post for some good suggestions on how to ask a technical question in the community.

Without any context, the best guess I have is that by using int you don’t need to wrap your keys in quotation marks in order to access its associated value in the dictionary. However, it’s more likely that you need to be able to treat the keys as numerical values for some other purposes (e.g. for doing calculations of some sort) that just aren’t possible if the keys are strings.