I have a dictonary in python how to access the value field?

0 votes

I have a dictionary like this

dic={"car":["limo","sedan"]}.

How can I access the sedan value here?

Dec 19, 2018 in Python by Jino
• 5,560 points
73 views

1 answer to this question.

0 votes

dic={"car":["limo","sedan"]}

print (dic.keys())    <-----------------------Fetch the key "car"

print (dic['car'][0])   <------------------------Fetch limo

print (dic['car'][1])    <------------------------Fetch sedan

answered Dec 19, 2018 by Shuvodip

Related Questions In Python

0 votes
1 answer
+2 votes
2 answers

In a list of dictionaries, how can I find the minimum calue in a common dictionary field.

There are several options. Here is a ...READ MORE

answered Apr 10, 2018 in Python by charlie_brown
• 7,720 points
53 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 175 views
+4 votes
6 answers
+3 votes
7 answers

How can I rename a file in Python?

yes, you can use "os.rename" for that. ...READ MORE

answered Mar 31, 2018 in Python by DareDev
• 6,810 points
115 views
0 votes
1 answer

How to get the current time in Python

>>> import datetime >>> datetime.datetime.now() datetime(2018, 25, ...READ MORE

answered Jul 25, 2018 in Python by Frankie
• 9,810 points
38 views