unsupported operand type(s) for -: 'str' 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 -: 'str' and 'int'

#this is a int
Anmol = 1

#this is a str
Mom = "1"

Anmol + Mom
#if you add you get someting that looks like this
#TypeError: unsupported operand type(s) for -: 'str' and 'int'
#to fix do the following

Anmol + str(Mom)

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

# use and in stead of & in python

Tags: