I’m currently taking the cs50p course on edx, and I’m currently stuck on the problem set8 Seasons of Love. We were suppose to write a code that calculates the amount of years a person has lived in minutes
But my code does match there’s in the test that they gave. I’m thinking if it has to do with the year I’m currently in ????
For example if I input a date from like a year ago today
Their code returns 525600 minutes But mine returns 570400.
`
from datetime import date
import sys
import operator
import inflect
p = inflect.engine()
def main():
date = input("Date of birth: ")
print(validate(date))
def validate(d):
try:
birth = date.fromisoformat(d)
except ValueError:
sys.exit("Invalid Format")
today = date.today()
difference = operator.__sub__(today,birth)
time = difference.days * 24 * 60
output = p.number_to_words(time)
return f"{output.capitalize()} minutes"
if name == “main“:
main()
Poky TV is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.