Doubts in python code how to use set method -


i excepting elements print prints hffdfd , fjdkl. why happens. here's code:

print (set({'hffdfd' : 'shfs', 'fjdkl' : 616})) 

because if iterate on dictionary, only obtain keys. next put these keys set print.

you can use following set comprehension print both keys , values:

d = {'hffdfd' : 'shfs', 'fjdkl' : 616} print(set(y x in d.items() y in x)) 

now construct set contains both keys , values.

if wish print dictionary itself, can use:

print ({'hffdfd' : 'shfs', 'fjdkl' : 616}) 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -