I have a dictionary with 100 entries like this..
d = {
'entrenched': ['the Internet is firmly entrenched in our lives.'],
'profoundly': ['racism is profoundly entrenched within different social spheres.']
}
I want to loop through the dictionary and replace one of the words in the value based on the key.
The output should look like this:
d = {
'entrenched': ['the Internet is firmly en... in our lives.'],
'profoundly': ['racism is pr... entrenched within different social spheres.']
}
I tried this code
for k,v in d.items():
for word in v:
if word == k:
gapped_word = word[1:]+ '...'
final_sentence = v.replace(word,gapped_word )
print(final_sentence)
but got no output. I'm also not sure what the final line should be if instead of printing I am replacing the original value with the adjusted one