Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13951

How to get all the items in a dictionary from a function

$
0
0

The function below returns the contents of the dictionary. Aside from returning the content of the dictionary, how to get all the names of the dict inside the function?

def get_ext(file_type):    xsds = {'this is 1st': ['a', 'b', 'c', 'd']}    rsksd = {'this is 2nd': ['1', '2', '3', '4']}    as2w = {'this is 3rd': ['a', 'b', 'c', 'd']}    return locals()[file_type]print (get_ext("xsds"))# Output{'this is 1st': ['a', 'b', 'c', 'd']}

Needed Output:

xsdsrsksdas2w

Viewing all articles
Browse latest Browse all 13951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>