TypeError: unsupported operand type(s) for +: 'dict' and 'str' code example

Example 1: python unsupported operand type(s) for /: 'str' and 'str'

# Error:
TypeError: unsupported operand type(s) for /: 'str' and 'str'
    
# Solution:
# You're probably mixing strings and integers. Make sure to either 
# convert integers to strings with str(int) or strings to integers/floats
# with int(string) or float(string) depending on what you're doing.

Example 2: TypeError: unsupported operand type(s) for +: 'int' and 'str'

do not combine int with string !
Example:int + string = error
correct example: int + int = no error 
                 string + string = no error

Example 3: TypeError: unsupported operand type(s) for +: 'dict' and 'dict'

d = dict1.copy()
d.update(dict2)

Example 4: python unsupported operand type(s) for & 'str' and 'str'

# use and in stead of & in python

Tags:

Cpp Example