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)