Question: Data from a .txt:

```
ABC 12 34 24
edf 23 15 63
hre 41 3  356
...
...

```

I want to save each word(in the first column) in a set. For each element in the set, have a list that contains each number after it. E.G. word[ABC][1] = 34, word[hre][2] = 356.

I don't find any useful information about this online.

Answer: 
Here's one way:

mkt.py 

```
words = {}
with open('a.txt') as f:
  for l in f:
    cols = l.split()
    word = cols[0]
    nums = [int(e) for e in cols[1:]]
    words[word] = nums

# Printing all words with their number lists
for k, v in words.iteritems():
  print("%s -> %s" % (k, v))

# Getting specific ones
print(words['ABC'][1]) # -> 34
print(words['hre'][2]) # -> 356

# Showing it's an int - doing some basic arithmetic operation
i = words['ABC'][1] + 50 # -> 84
print(i)

```

a.txt 

```
ABC 12 34 24
edf 23 15 63
hre 41 3  356

```

Running:

```
$ python mkt.py 
hre -> [41, 3, 356]
ABC -> [12, 34, 24]
edf -> [23, 15, 63]
34
356
84

```
This is a good time to use generators to conserve memory even on large files.

Here I simulate the file using a multiline string.

```
file_ = """ABC 12 34 24
edf 23 15 63
hre 41 3  356""".splitlines()

rows = (line.split() for line in file_)
pairs = ((row[0], map(int, row[1:])) for row in rows)
d = dict(pairs)

for key_ in d:
    print key_, d[key_]

"""
>>>
hre [41, 3, 356]
ABC [12, 34, 24]
edf [23, 15, 63]
"""

print d['ABC'][1]
"34"

```