position_list = ['front', 'frnt', 'ft', 'back', 'bck', 'behind', 'right', 'rhs']
position = ['down', 'right', 'inner', 'front', 'top', 'back', 'left']
These are the two lists I'm working on in PYTHON. For a given text if any of the words in position_list occurs, it must be replaced with specific words in position.
i.e text is : "The frnt tyre and bck tyre are worn out"
The 'frnt' and 'bck' must be replaced with 'front' and 'back' respectively.
The python code I used is:
if wrong == 'frnt' or wrong == 'ft':
str = str.replace(wrong,'front')
if wrong == 'bck' or wrong == 'behind':
str = str.replace(wrong,'back')
But I'm looking for python codes which directly replaces words using these lists.