I want create dictionaries when a new word comes from a files, to store filename and position in that dictionary of that word.

E.g:

```
file1="This is apple"
file2="This is mango"

```

Dictionaries be like:

```
this={file1:0,file2:0}
is={file1:5,file2:5}
apple={file1:8}
mango={file2:8}

```

My code for retrieving the words:

```
files=['sample1.txt']
for filename in files:
    file = open(filename, 'r')

    dict={}
    for line in file:
        for word in line.split():
            word_name=word
            if((word_name not in dict.keys())):
                word={}      # here the different dictionaries should be created 
                dict[word_name]=0
            dict[word_name]+=1

```

here 'dict' dictionary is storing the word and occurrences. 

Any suggestions ?