+ 1

How to do this question in Python? Help...

Can someone tell me how to do this question in python. Question: What is the output of this code? a = ‘b’ b = {a: ‘a’, ‘a’: a} print(b[a])

29th Dec 2017, 12:08 PM
Sai Sathvik
Sai Sathvik - avatar
2 Answers
+ 2
a = 'b' b = {a:'a' , 'a':a} but a = 'b' this basically means the key a='b' has the value 'a' and the key 'a' has the value 'b' b = { 'b' : 'a' , 'a' : 'b' } now print the value of the key a='b' in the dictionary named b , which is 'a'
29th Dec 2017, 12:27 PM
Nawwar
Nawwar - avatar
0
Thank you
29th Dec 2017, 12:28 PM
Sai Sathvik
Sai Sathvik - avatar