简体   繁体   中英

Print Error in Python 3.4

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=' ')

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM