Q:

Python : Separating the terms in a list and assigning values

I have used a keyword extractor and obtained a list as given below-
[('solutions design team', 0.5027793039863974), 
('communication skills', 0.039048703166463736), 
('internal stakeholders', 0.03230578820017667),
('potential customers', 0.020380881551651655), ('utilize', 0.002776174060064261)]

I'm trying to separate each of these words and assign the corresponding value(given on the right) to each of them respectively.
For eg- Make 'solutions design team' = 0.5027793039863974 into 
'solutions' = 0.5027793039863974, 
'design' = 0.5027793039863974 ,   
'team' = 0.5027793039863974.

A:

what about using double flat comprehension to re-create a list of tuples with separated words:
inlist = [('solutions design team', 0.5027793039863974),
('communication skills', 0.039048703166463736),
('internal stakeholders', 0.03230578820017667),
('potential customers', 0.020380881551651655), ('utilize', 0.002776174060064261)]

outlist = [(word,value) for words,value in inlist for word in words.split()]

result:
>>> outlist
[('solutions', 0.5027793039863974),
 ('design', 0.5027793039863974),
 ('team', 0.5027793039863974),
 ('communication', 0.039048703166463736),
 ('skills', 0.039048703166463736),
 ('internal', 0.03230578820017667),
 ('stakeholders', 0.03230578820017667),
 ('potential', 0.020380881551651655),
 ('customers', 0.020380881551651655),
 ('utilize', 0.002776174060064261)]

note that if the keywords are present more than once, you'll have duplicates in the list of tuples. If you want to accumulate them, a collections.defaultdict(float) object could be handy to create a dictionary with keywords=>accumulated values.
accumulated = collections.defaultdict(float)
for word,value in outlist:
    accumulated[word] += value

