Here , we are going to learn basic python code to make function which can create list of word from given string.

Code:

def extWord(strVar):
    wrdList = []
    start = 0
    end = 0
    for i in strVar:
        if i == ' ':
            wrdList.append(strVar[start:end])
             start = end + 1      
    end += 1 
    wrdList.append(strVar[start:end])
    return wrdList

Output:

extWord(“john rock mahesh ram”) >>> [‘john’, ‘rock’, ‘mahesh’, ‘ram’] So using this function we can extract each words from a given string and store them into list and later we can use them as per our requirements.