The dictionary is empty, which is why dict[5] says that no such key exists. You probably want dict[i] = [f] instead, that way a new array is assigned there.
If you actually treat the Dict as a collection and want to push to it though, it should work.
Also, the question is what do you want to push in. Did you want an array of file names stored as value in the dict (i.e. [f]) or do you want to store the fiile name itself. Your initialization of the dict doesn’t match any of these.