• 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

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,240 points

Related questions

2 votes
1 answer 108 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 Gavin 15.3k points
0 votes
1 answer 4 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 Mashhoodch 1.2k points
0 votes
1 answer 34 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 Ahsan 1.8k points
0 votes
1 answer 30 views
Problem: Hello kodlogs, How can we use for loop in the python to iterate over the sequence of element I have a confusion over the range() function and the datatype like list, tuple and string. Like how can we access the elements in the list
asked Jun 9 Gavin 15.3k points
1 vote
1 answer 25 views
Problem: Hello guys, I’ve got a python list full of data. I want to print them reversely. The only condition that has to follow is to use a for-loop in the program. I know there could be several ways to do that but I want for-loop to do that. ... you've any suggestion in this regard? Please, keep your answer as simple as possible. It would be helpful for me to understand well. Thanks.
asked Jun 2 adamSw 11.3k points