Trying to change a embed footer text with a for loop

Question:

for footer in embed_dict["footer"]:
    footer["text"] = "new text"
embed_new = discord.Embed.from_dict(embed_dict)
await messageraids.edit(embed=raidedit1embed) 

I get the error:

footer["text"] = "new text"
TypeError: 'str' object does not support item assignment

Anyone know how to fix this

Asked By: Daniel Andersen

||

Answers:

Based on your comment clarifying that embed_dict["footer"] contains {'text': '0/10 Total'}, your problem is you’re iterating over that value in the line:

for footer in embed_dict["footer"]:

Doing so iterates over the keys of that dictionary, so footer has a value of 'text', and you’re doing footer["text"] = "new text", which you can’t do on a string. You should simply do:

embed_dict["footer"]["text"] = "new text"
Answered By: Mihai Chelaru
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.