Position of Target Word (Problem 36) - InfyTQ Solution in Python
Position of Target Word (Problem 36)
InfyTQ Solution in Python
PROBLEM STATEMENT
[Massachusetts Institute of Technology 6.00 Final Spring 2011]
Part-1:
Write a python function which accepts a string of words and a target word, and returns the list of the positions of the target word in the string of words.
Part-1:
Write a python function which accepts a string of words and a target word, and returns the list of the positions of the target word in the string of words.
Sample Input | Expected Output |
---|---|
input String- we dont need no education we dont need no thought control no we dont target word- dont | [1, 6, 13 ] |
Write a python function which accepts a string of words and returns a dict which contains the words in the input string as key and the list of positions of these words in the input string as value. Use the function written in part-1.
Sample Input | Expected Output |
---|---|
we dont need no education we dont need no thought control no we dont | {'no': [3, 8, 11], 'thought': [9], 'dont': [1, 6, 13], 'need': [2, 7], 'control': [10], 'we': [0, 5, 12], 'education': [4]} |
SOLUTION
SHARE
If you find this useful, please share with your friends and Community.
CODE TOGETHER..GROW TOGETHER.
CODE TOGETHER..GROW TOGETHER.
Newer Posts
Newer Posts
Older Posts
Older Posts
Comments