TypeError: Can only concatenate str (not “int”) to str (simple Python programme)

The input() command in line 2 of your code would turn any input provided by the user into a STRING. Therefore, when you try to add that STRING to a number (float or integer; in your case you have an integer i.e. factor=2) it won’t (and shouldn’t!) work.

Therefore, for the + operation to continue, both the quantities to the left and right of that + sign must be of the same type (strings, or numbers)

Leave a Comment