Since str.split also defaults to '\t' ( '\t' is considered a space), you can get a functional dict approach with map , which looks pretty elegant:
d = dict(map(str.split, list1))
Now that the d dictionary is in the desired form:
print(d) {'and': 'CONJ', 'go': 'VERB', 'have': 'VERB', 'tree': 'NOUN'}
If you only want to split into '\t' (while ignoring ' ' and '\n' ) and still want to use the map approach, you can create a partial object with functools.partial that uses '\t' as a separator:
from functools import partial # only splits on '\t' ignoring new-lines, white space etc tabsplit = partial(str.split, sep='\t') d = dict(map(tabsplit, list1))
this of course gives the same result for d using an example list of strings.
source share