Home > Net >  TypeError: unsupported operand type(s) for *: 'Future' and 'int' while running c
TypeError: unsupported operand type(s) for *: 'Future' and 'int' while running c

Time:07-23

Received error on converting min_1 variable to int(min_1) in line 6

I have started off with learning python with the help of resources available on the internet and Think Python book by Allen B.Downey. I encountered a question which mentioned conversion of minutes to seconds. However, I am facing an error w.r.t. type of the variable min_1.

I tried converting the variable to int as well which is giving different error. Please guide!

CodePudding user response:

Remember that the outcome of input is a string. Therefore please try:

min_1 = int(input("How many minutes?"))

And then

min_to_sec = min_1 * 60 

Should work correctly

CodePudding user response:

Return type of input() is string, which needs to be type casted to int, or float as per your input.

The code below works fine.

min_1 = int(input("How many minutes"))
sec = int(input("How many seconds"))

min_to_sec = min_1 * 60
total_time = min_to_sec   sec

print("Total time: ", total_time)

  • Related