Write a for loop to print each contact in contact_emails. Sample output for the given program:

mike.filt@bmail.com is Mike Filt
s.reyn@email.com is Sue Reyn
narty042@nmail.com is Nate Arty
Code:

contact_emails = {
'Sue Reyn' : 's.reyn@email.com',
'Mike Filt': 'mike.filt@bmail.com',
'Nate Arty': 'narty042@nmail.com'
}

for email in contact_emails:
print('%s is %s' % (email, contact_emails(email)))

Respuesta :

Answer:

Correct code for the above question which is written in the place of loop in the above question code:

for a,b in contact_emails.items(): # for loop to print the above items one by one.

   print(str(b)+" is "+str(a)) # print statement to print the item of the list.

Output:

  • The above code is in python language which display the output as the above question demands.

Explanation:

  • The above question code is in python language, so the for loop to prints the list is defined in the answer part.
  • The for loop syntax defined in the question part is not correct. It never gives the output which the question demands.
  • The above list defined in the question part is in the form of key-value pair which comes in the categories of the dictionary concept.
  • So to print the above list, any user needs an item function that will display the output in the key-value pair.
  • There is also needs two variables in the 'for' loop one is for key and the other is for value.

In this exercise we have to use the knowledge of programming in python code  to describe a looping so we have the code.

The code can be found in the attached image.

How to loop a code?

Repeat commands are a feature that allows a certain piece of code in a program to be repeated a certain number of times. In C there are three repetition commands: while, do-while and for.

See more about python at brainly.com/question/26104476

Ver imagen lhmarianateixeira