Reputation: 3125
I have kinda a tricky problem I want to solve. I have two lists:
word = ['run', 'windless', 'marvelous']
pron = ['rVn', 'wIndl@s', 'mArv@l@s']
I want to do some processing that if the value in word
contains "less", then the corresponding value in pron
should turn to "lIs" instead of "l@s".
Desired output:
pron = ['rVn', 'wIndlIs', 'mArv@l@s']
Any tips? It's troublesome to me because they're in two separate lists (but same order).
Upvotes: 0
Views: 147
Reputation: 16556
Do you mean something like that?
>>> for i,w in enumerate(word):
... if 'less' in w:
... pron[i] = pron[i].replace('l@s','lIs')
...
>>> pron
['rVn', 'wIndlIs', 'mArv@l@s']
Upvotes: 3
Reputation: 4130
words = ['run', 'windless', 'marvelous']
prons = ['rVn', 'wIndl@s', 'mArv@l@s']
for (i, word) in enumerate(words):
if "less" in word:
prons[i] = prons[i].replace("l@s", "lIs")
print(prons)
Upvotes: 4