What is happening with the line?

Do this:
(result dictionary)
tmp = [result[i] for i in sorted(result .keys())]
result = ".join(tmp)

what get the following error:
str object doesn't support item assignment

What's the problem?
July 8th 19 at 16:15
2 answers
July 8th 19 at 16:17
In python strings are immutable type(immutable), and hints on what type errors. The following piece of code(two lines - a piece of code yeah damn it) no syntax errors(unless the gap in method sorted). Most likely then you are trying to change the characters in the string result. Look closely at tracebak what line I get an error.
July 8th 19 at 16:19
result = {'key': 'value','ke1': 'value1'}

tmp = [result[i] for i in sorted(result .keys())]
result = ".join(tmp)

everything works
it should work but not working - tierra_Schill commented on July 8th 19 at 16:22
: check result = {'key': 'value','ke1': 'value1'}. all key and value must be str, not int, float or something else - Karine.Greenfelder commented on July 8th 19 at 16:25

Find more questions by tags Python