lilgov602 lilgov602
  • 22-10-2020
  • Computers and Technology
contestada

Complete the following code snippet so that all of the negative values my_dict will be changed to zero. for key, value in _______: if value my_dict[key]

Respuesta :

IfeanyiEze8899 IfeanyiEze8899
  • 27-10-2020

Answer:

for key, value in my_dict.items():

   my_dict[ key ] = 0 if value < 0

Explanation:

Dictionary in python is an unordered and unindexed data structure, which is arranged in key-value pairs. To loop through the dictionary, the items() method is used on the dictionary finding the key and value on each iteration.

A value can be retrieved and changed using bracket notation and the key name of the value in question.

Answer Link

Otras preguntas

What are the coordinates of the vertex for f(x) = 2x2 + 4x + 9?
Suppose a line L has an equation Ax+By+C==0, what is the slope of L if B=0 and A does not equal 0
which of the following summary statements best illustrates flashback? A. Mrs. Perez calls the police after discovering that her house has been broken into.
what rhetorical appeal or appeals was used in Thomas Paine's the American crisis pamphlet BEST ANSWER GETS BRANLIEST
imagine you are doing an interview with a former viet cong fighter what migh he say about his interstate in fighting the war
what is a problem using nuclear energy causes?
what does the author mean by saying that dropping a unclear bomb "strikes at the very basis of moral existence ?
In any given year, about ______ percent of adults over the age of 18 suffer from a mental disorder.
what was the purpose for the attack on pearl harbor
The framers feared that too much power in any government would lead to