Convert year to seconds in Python

Question:

I’m stuck on an assignment which needs me to convert an input of years and print the result in seconds. The error message I get when I run the function is:

'*TypeError: not all arguments converted during string formatting*'

I can’t really get my head around what’s wrong…

def ageInSeconds():
    """
    Reads the age and converts to seconds.
    """
    ageYears = int(input("Tell me your age, please: "))
    seconds = ageYears * (365*24*60*60)
    print("nBatman says you age in seconds is: " % seconds)
Asked By: Thomas Bengtsson

||

Answers:

You are missing a %d inside the string.

print("nBatman says you age in seconds is: %d" % seconds)
                                             ^

Else you can do

print("nBatman says you age in seconds is:",seconds)  # Inbuilt feature of the print function
Answered By: Bhargav Rao
Years = int(input("Tell me the year, please: "))

answer = Years * (365*24*60*60)

print("There are", answer, "seconds in a year/years")
Answered By: Sivario Buchanan
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.