a={ 1:'a', 2:'b', 3:'c'} for i,j in a.items(): print(i,j,end="#") | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

a={ 1:'a', 2:'b', 3:'c'} for i,j in a.items(): print(i,j,end="#")

Please tell

28th Jan 2022, 7:28 AM
Sampada Sharma
2 Answers
0
What to tell?? It has indentation error🙄 Click tab on line 3rd line (before print)
28th Jan 2022, 7:31 AM
NEZ
NEZ - avatar
0
Sampada Sharma a={ 1:'a', 2:'b', 3:'c'} First of all you are creating a dictionary with three keys with three values and you are storing it in a variable a(to be specific you are making variable 'a' to reference the dictionary) for i,j in a.items(): Now you are traversing the dictionary 'i' --> stores all the keys 'j' --> stores all the values as .items function(method) returns the data like this ([(1, 'a'), (2, 'b'), (3, 'c')]) ( to be specific dict_items([(1, 'a'), (2, 'b'), (3, 'c')])) print(i,j,end="#") now we are printing the result . As we have used end = '#' . Every new line starts with # Your overall code should look like this a={ 1:'a', 2:'b', 3:'c'} for i,j in a.items(): print(i,j,end="#") output: 1 a#2 b#3 c# ㅤㅤㅤ this is what he is asking for
28th Jan 2022, 7:40 AM
hamishhr
hamishhr - avatar