I am starting learning python and I cant see what error I made. Please check my error and tell me.
response = float(input("What time is it? (In hours) "))
second_response = float(input("How many hours to wait? "))
if (response + second_response) < 24:
final_hour = response + second_response
if response + second_response > 24:
final_hour = response + (second_response - ((second_response // 24) * 24)
print("The clock will be on " + str(final_hour) + " hours. ")
In terms of the code, Iām not a Python guy, but in your second to last line, I think you need to count your parentheses.
In terms of the algorithm, what happens if (response + second_response)
is exactly equal to 24? Try it out.
You forgot to close some parenethes.
1 Like
here is a correction by me for your codes, run it and you wont see errors
response = float(input("What time is it? (In hours) "))
second_response = float(input("How many hours to wait? "))
if response + second_response < 24:
final_hour = response + second_response
else:
final_hour = response + second_response - ((second_response // 24) * 24)
print("The clock will be on " + str(final_hour) + " hours. ")
1 Like
On 6th line, add a closing parentheses to the end