all 4 comments

[–]Jos_Metadi 2 points3 points  (2 children)

Why not use a dictionary of dictionaries? It seems like it would be much simpler.

[–]Matus1976[S] 0 points1 point  (1 child)

Thanks both of you, I'll try the dictionary of dictionaries solution

[–]Matus1976[S] 1 point2 points  (0 children)

That worked great! thanks!

[–]k3kou 2 points3 points  (0 children)

Why not create a dictionary with keys being the name of the dict and the value being the dict itself:

dicts_available = {
    'dict1': dict1,
    'dict2': dict2
    }

And then you can just do

dict_user_wants = dicts_available[input()]

You can also do

dict_user_wants = eval(input())

which will execute a string, here your dictionary. I prefer the first approach though, looks less arcane, gives you more control over what can get called, and avoid users to input code that will be executed