How To Extract Only Value From Dictionary In Python
Python Dictionary Is Used To Store Data In Key:Value Pair
Python Dictionary Syntax
dict={"Car":"Lamborghini","Mobile":"iPhone"}
print(dict)
Output
How To Show Only Value From Dictionary
If You Want To Show Only Value , Instead Of Key:Value , Then We Need To Use For Loop & Will Print Only Value Instead Of Key
dict={"Car":"Lamborghini","Mobile":"iPhone"}
for thevalue in dict.values():
print(thevalue)
Output
How To Show Only Values Stored In List Form In Dictionary
If A Dictionary Has Key:Value Pair In Which There Are Multiple Values Stored In List Form , Then To Show All The Values Use The Following Code
dict={"Car":["Lamborghini","BMW","Mercedes"],"Mobile":["iPhone","OnePlus","Samsung"]}
for thevalue in dict.values():
print(thevalue)
Output
How To Show Only Values Stored In List Form In Dictionary On New Line
As We Have Seen In Above Code , The Output Values Appear On Same Line. To Show Each List Items On New Line , We Need To Use For Loop Again & Separate Values On New Line
dict={"Car":["Lamborghini","BMW","Mercedes"],"Mobile":["Iphone","OnePlus","Samsung"]}
nd = [value[i] for value in dict.values()
for i in range(2)]
print(*nd,sep="\n")
1 comment
'age': [ 25,23,2,30,28],
'Nplace': ['tirupati','puttoor','Ballari','banglore','chittoor']}]