0

How to print a dictionary like {a: 1, b:4, c:9, d:16, e:25} using for loop?

Using loop can we create and print this series of dictionary - {a:1,b:4,c:9,d:25,e:36,f:49....}

26th Apr 2019, 5:08 AM
Arnab Nayak
Arnab Nayak - avatar
4 Respuestas
+ 3
With str(chr(97)) you create an a. str(chr(98)) = "b" This might help you. :)
26th Apr 2019, 5:54 AM
Dragonxiv
Dragonxiv - avatar
+ 2
Do you have some code where you tried it but got stuck? Otherwise its hard to help you. Just giving you the answer wont help you to become a programmer.
26th Apr 2019, 5:11 AM
Dragonxiv
Dragonxiv - avatar
0
Here is the code that is like {1:1,2:4,3:9,4:16,5:25.....n:n²} But if we want to change the key part in alphabetical order. For that can we generate generate the series like {a:1,b:4,c:9,d:16......} https://code.sololearn.com/ctbOCDr2Y5Kv/?ref=app
26th Apr 2019, 5:30 AM
Arnab Nayak
Arnab Nayak - avatar
0
Yes, thank you, will learn about it and implement it on my code.
26th Apr 2019, 5:56 AM
Arnab Nayak
Arnab Nayak - avatar