First of all, let me say that I read the many threads with similar topics on creating dynamically named variables, but they mostly relate to Python 2 or they assume you are working with classes. And yes, I read [Behavior of exec function in Python 2 and Python 3](https://stackoverflow.com/questions/15086040/behaviour-of-exec-function-in-python-2-and-python-3). 

I'm also aware that creating dynamically named variables is a bad idea in 99% of time and dictionaries are the way to got, but I just want to know whether it is still possible and how exactly exec and locals work in python 3.

I'd like to show a bit of sample code illustrating my question (fibonacci calculates fibonacci numbers, ListOfLetters provides ["A", "B", ...]):

```
def functionname():
    for index, buchstabe in enumerate(ListOfLetters.create_list("A", "K"), 1): 
        exec("{} = {}".format(buchstabe, fibonacci(index)) ) #A = 1, B = 1, C = 2, D = 3, E = 5,...
        print(index, buchstabe, eval(buchstabe)) #works nicely, e.g. prints "4 D 3"
    print(locals()) #pritns all locals: {'B': 1, 'A': 1, 'index': 11, 'C': 2, 'H': 21, 'K': 89, ...
    print(locals()['K']) #prints 89 as it should
    print(eval("K")) #prints 89 as it should
    print(K) #NameError: name 'K' is not defined

```

So at least at my current understanding, there is some inconsistency in the behaviour of `locals()`, since it contains the variable names added by `exec()` but the variables are not available in the function.

I would be greatful if someone could explain this and tell whether this is by design or if it is a real inconsistency in the language. Yes, I know that [`locals`](https://docs.python.org/3/library/functions.html#locals) should not be modified , but I'm not modifying it, I'm calling `exec()`...