String concatenate TypeError: can only concatenate str (not “int”) to str”

This should fix it:

salaries['John'] = str(int(salaries['John']) + 30)

You need to convert the salaries of John to an int add 30 and then convert it back to a string.

This will change salaries['John'] from 20 to 50

Leave a Comment