Looping over dictionary values

0 votes
I want to create a loop that iterates over the values of a python dict. Please don't paste code on looping over dict keys.
Apr 17, 2018 in Python by donkeykong
20 views

1 answer to this question.

0 votes

You can loop over the dictionary and extract the values using the items() function:

for key ,value in dictionary.items():
    #loop body

Here "key" and "value" are the variables that contain the key and the value of the dictionary extracted on every iteration of the loop.

answered Apr 17, 2018 by Nietzsche's daemon
• 4,260 points

Related Questions In Python

0 votes
1 answer

How to find count/length of dictionary values of list?

You should have used d.itervalues() instead and ...READ MORE

answered May 13 in Python by John
12 views
+2 votes
2 answers

How can I replace values with 'none' in a dataframe using pandas

Actually in later versions of pandas this ...READ MORE

answered Aug 13, 2018 in Python by bug_seeker
• 15,350 points
5,663 views
+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
62 views
0 votes
1 answer

Iterating over multiple lists

import itertools for item in itertools.chain(listone, listtwo): #lis ...READ MORE

answered Apr 25, 2018 in Python by Nietzsche's daemon
• 4,260 points
26 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 228 views
+4 votes
6 answers
0 votes
1 answer

Looping over two lists at once

You have to use the zip() function: for ...READ MORE

answered May 15, 2018 in Python by Nietzsche's daemon
• 4,260 points
158 views
0 votes
1 answer

Looping over a string in python

for c in "string": ...READ MORE

answered May 28, 2018 in Python by Nietzsche's daemon
• 4,260 points
20 views