Question: ```java
import java.util.HashMap;

public class Map {

   public static void main(String[] args) {
       // TODO Auto-generated method stub

       int arr[] = {10, 3, 34, 3, 10};

       HashMap<Integer, Integer> hmap=new HashMap<Integer, Integer>();

       for (int i = 0; i < arr.length; i++) {
           System.out.println(hmap.put(arr[i], 1));
       }
   }
}

```

I am getting the output as below:

```none
null
null
null
1
1

```

I am not getting why am I getting the output as three times `null` and two times one.

Answer: 
You can do so using [`collections.defaultdict`](https://docs.python.org/3/library/collections.html#collections.defaultdict)

```
import collections

fileName = input("Enter file name:")
match = open(fileName)
table = []

for line in match:
    contents = line.strip()
    table.append(contents)

scores = collections.defaultdict(int)
for line in table:
    teamA,teamB,scoreA,scoreB = line.split(':')
    # even if scores does not have the team key, += will create it
    scores[teamA] += int(scoreA)
    scores[teamB] += int(scoreB)

```
Try this:

```
f = open('filename.txt').readlines()

f = [i.strip('\n') for i in f]

f = [i.split(':') for i in f]

dct = {}

for i in f:
   for b in range(len(i[:2])):
       if i[:2][b] not in dct.keys():
           dct[i[:2][b]] = int(i[2:][b])

        else:
           dct[i[:2][b]] += int(i[2:][b])
print dct

```