0

Why am I getting a syntax error on the print function lines? I've Tried it without the end=' ' in the brackets but still not working. I want to have all the print functions on one line.

#This program will convert a given amount
#of seconds into hours, minutes, seconds format

total_time = int(input("Number of Seconds"))
hours = int((total_time//(60*60)))
minutes = int(((total_time/60)-(hours*60)))
seconds = int((total_time-(hours*3600)-(minutes*60))

print('There are', end=' ')
print(hours, end=' ')
print('hours', end=' ')
print(minutes, end=' ')
print('minutes,',end=' ')
print('and', end=' ')
print(seconds, end=' ')
print('seconds', end=' ')
print('in', end=' ')
print(total_time, end=' ')
print('seconds', end=' ')
1
  • 1
    You may want to use an IDE/editor that can help you avoid such mistakes. I recommend picking up vi slowly while working with jetbrains' pycharm. Commented Jan 20, 2015 at 0:45

1 Answer 1

4

You are missing a closing paren:

seconds = int((total_time-(hours*3600)-(minutes*60)) # <- missing closing

should be:

seconds = int((total_time-(hours*3600)-(minutes*60)))

FWIW often the error is on the line before what you see in the traceback

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.