How to fix "TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'"?
In python3, print
is a function that returns None
. So, the line:
print ("number of donuts: " ) +str(count)
you have None + str(count)
.
What you probably want is to use string formatting:
print ("Number of donuts: {}".format(count))
Your parenthesis is in the wrong spot:
print ("number of donuts: " ) +str(count)
^
Move it here:
print ("number of donuts: " + str(count))
^
Or just use a comma:
print("number of donuts:", count)