key = '<unknown>'
category = defaultdict(list)
for i in x:
    if i.isalpha():
        key = i
else:
    category[key].append(i)
print(category)
How to add values in keys in a dictionary inside a loop?