• Register
2 votes


Hello good soul,

I am a newbie in python programming. I am having a problem printing both the name on the list and the email. Let me put it this way, I want to write a for loop to print each contact in contact_emails.
Any solution will be much appreciated.

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

2 votes


As per your question, I understood you want to use a for-loop to print each contact in contact_emails. It means you are willing to print both of the strings in a particular dictionary.

Let’s define some contact_emails first and then use the for-loop to print both of the strings below:

contact_emails = {
'Naymul Hasan' : 'n.hasan@gmail.com',
'Fuad Mostofa': 'mostofa.fuad@ymail.com',
'Rifat Rahman': 'rrahman@gmail.com'

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

This program will throw back the output below:

n.hasan@gmail.com is Naymul Hasan  
rrahman@gmail.com is Rifat Rahman  
mostofa.fuad@mail.com is Fuad Mostofa  

Hope this helps you. Thanks.

13 9 6
94,260 points

Related questions

0 votes
1 answer 8 views
Problem: Can anyone help me about this? If anyone know about loop to print each contact and contact email. Then please read my question carefully and answer me.
asked Mar 26 niyatiry 3.9k points
0 votes
1 answer 3 views
Problem: Hey So I'm working on a problem that asks me to manipulate a dictionary by grabbing all the keys and values and formatting them into a single string for every key/value pair. I have to do this in one line. How can I do that?
asked 5 days ago muktaa 34.6k points
0 votes
1 answer 16 views
Problem: I'm sure this is super simple, but I keep getting nothing. The instructions say: "Write code that prints: firstNumber...2 1 Print a newline after each number. Ex: firstNumber = 3 outputs 3 2 1 Here's: the code: public class ForLoops { public static void main (String ... i equal to 3, then it will count down for everything until i equals or is less than 1 with the --i. If that makes sense.
asked Apr 24 sumaiya simi 43.9k points
2 votes
1 answer 301 views
Problem: Hi all, I am an entry-level student in Python programming. I have got an assignment from my lecturer to write a program that prints a diamond shape made of *. Well, I want to learn from the very basics. As I understood it might be the very basics of printing ... to write a nested loop program to print a rectangle. sample output for the given program below: * * * * * * Thanks in advance
asked Mar 17, 2020 Gavin 15.3k points
0 votes
1 answer 5 views
Problem: i want to know about that what is for each loop in java?
asked Apr 13 jamuna1 30.2k points
0 votes
1 answer 13 views
Problem: Attention reader! Det hold of all the important Java and Collections concepts with theat a student-friendly price and become industry ready.Please write relevant answer if you find anything correct, or you want to share more information about the topic discussed above.
asked Dec 12, 2020 Mashhoodch 13k points
1 vote
1 answer 6 views
Problem: I am pretty new to C++ language and therefore I need help to know. C++ for each loop vector.
asked Apr 23 PkGuy 23.5k points
0 votes
1 answer 6 views
Problem: I can't figure out how to do a for loop with a start number of -5 and end number of 6. int startNumber int endNumber int I startNumber = -5 endNumber = 6; for( i = -5; i > endNumber; i++) cout << i << /n
asked May 1 ochena 23.3k points
0 votes
1 answer 18 views
Problem: Hello When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop: Statement 1 is executed (100 time) before the execution of the code block. Statement 2 defines the condition for executing the code block. Statement 3 is executed (every time) after the code block has been executed.
asked Nov 3, 2020 Mashhoodch 13k points
0 votes
1 answer 182 views
I need help with the basics, I need to print 1 to100 numbers in python. Please explain with the help of an example.
asked Oct 10, 2020 Ahsan 1.8k points