Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a dictionary such that the key is the title of the values and the value is a list for example:
Python
dict = {'name':['a','b','c'], 'price':['0.66','1.50','0.49'], quantity:['10','5','7']}

and I would like this to be something like:
Python
dict = {'name':['a','b','c'], 'price':[0.66,1.50,0.49], quantity:[10,5,7]}

where the numbers are there values.

p.s. sorry if i got anything wrong I don't really know what I'm doing.

What I have tried:

{k:int(v) if v.isdigit() else v for k,v in s.items()}
Posted
Updated 10-Jul-17 6:41am

1 solution

Use the appropriate built-in function: 2. Built-in Functions — Python 3.3.6 documentation[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900