问题
I am in an intro to programming class and we're making a calculator to figure out how many times a human heart has beaten given the number of years someone has been alive, and I keep getting unexpected EOF while parsing on the last line of code, can someone help me figure out why?
input("What is your name? ")
age= float(input("How old are you? "))
print("The average human heart beats 70 times a minute.")
beats_per_hour = 70 * 60
beats_per_day = beats_per_hour * 24
beats_per_year = beats_per_day * 365
beats_age = beats_per_year * age
print(format("Beats per minute: 70"))
print(format("Beats per hour:",beats_per_hour))
print(format("Beats per day:",beats_per_day))
print(format("Beats per year:",beats_per_year))
print(format("Your heart has taken",beats_age,"beats, since you were born.")enter code here
回答1:
I believe that your immediate problem is that you forgot the closing parenthesis on the last line: note how you have only one R_PAREN at the end of that one, but two on all the others. Also, do you want to save the user's name in line 1?
Here's a link to help with keyboard input.
来源:https://stackoverflow.com/questions/32387372/unexpected-eof-while-parsing-in-python