Q:

Creating a dictionary of lists from a single list?

I have a question about dicts. I'm a noob and have been looking through this topic extensively, but I can't seem to wrap my head around it. What I am trying to do is take this huge list I have from a text file(12 million terms), put it in a dict, and take items that share certain characteristics and put them in one list in the dict so when I search through the dict, every element with that characteristic is displayed.
Example of some list elements:
0022 hello https:example.com/blah

0122 john https:example.com/blah

3502 hello https:example.com/blah

Now according to the data above, I would like to have a dict element which is a list of every time the word "hello" appears and with "hello" as the key, so when I search "hello" I would return 
0022 hello https:example.com/blah

3502 hello https:example.com/blah

Any tips on how to do this efficiently?
I know a database is probably a faster and better solution, but I know nothing about DB, I'm not even a CS student I'm just taking an elective. Thank you for your help

A:

As suggested, a defaultdict(list) is perfect for doing this:
from collections import defaultdict

data = defaultdict(list)

with open('input.txt') as f_input:
    for line in f_input:
        key = line.split()[1]
        data[key].append(line)

print(''.join(data['hello']))

Which would display the lines:
0022 hello https:example.com/blah
3502 hello https:example.com/blah

