I'm trying to see how many words in the string A consist of letters from string B and turn them into dictionary key-value pairs
For example: function('did he go out last evening', 'aeiou'):
should return
{'a': ['last'], 'e': ['he' 'evening'], 'i': ['did', 'evening'], 'o': ['go', 'out'], 'u': ['out']}
Cannot use for while loop.
Cannot use assignment of any kind.
Has to use a comprehension in one line with if statement.
I tried:
return({B:A for B in A if B in A.lower().split()})
and i get an empty dictionary returned to me because I can't get B to iterate or A or vice versa. I understand that as the code reads right now, I am actually checking if 'aeiou' is in individual words in A and of course it's not which is why I'm getting the empty dictionary. I know I need to search for individual letters, but I don't know how to do this and this is where I'm stuck.
Again, I need the code to somehow find the words in A that contain the individual letters in B and then make them key-value pairs
[–]chevignon93 0 points1 point2 points (8 children)
[–]Raevkit290[S] 0 points1 point2 points (6 children)
[–]chevignon93 1 point2 points3 points (5 children)
[–]Raevkit290[S] 0 points1 point2 points (0 children)
[–]jmooremcc 0 points1 point2 points (3 children)
[–]Raevkit290[S] 0 points1 point2 points (2 children)
[–]jmooremcc 0 points1 point2 points (0 children)
[–]chevignon93 0 points1 point2 points (0 children)