pythontetris

TypeError: can only concatenate str (not "int") to str but when trying to change var's to str, I get a different error


So, I'm trying to make a PPS (Pieces Placed Per Second) Calculator For Tetris In Python. However, when I try to divide the time and pieces I get this error:

TypeError: can only concatenate str (not "int") to str

And some people on the site say something like "Convert the int to a str!" But when I do that, I get this error:

TypeError: unsupported operand type(s) for /: 'str' and 'str'

Here is the code:

pieces = input("How many pieces did you place? ")
time = input("How long did you play for? (In Seconds Please!) ")
PPS = " "


def answer():
    PPS = round(str(time) / str(pieces))
    print("Your PPS is: " + PPS)


answer()

Please help soon and thanks!


Solution

  • I already fixed the problem. The problem being I needed to change Time and Pieces To float(time) and float(pieces) and it works.