how to extract a word from a string in python