Skip to content

day 2 error #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
II-Tom-Cat-II opened this issue Jun 8, 2022 · 3 comments
Closed

day 2 error #58

II-Tom-Cat-II opened this issue Jun 8, 2022 · 3 comments
Assignees

Comments

@II-Tom-Cat-II
Copy link

Hello,

I am trying to figure out what went wrong with my code for the day 2 challenge. I am pretty sure the result is correct.
Which for challenge one is 2017. 07.08 and 505 days for challenge 2.

Challenge :

  1. We kicked off our 100 Days of Code project on March 30th, 2017. Calculate what date we finished the full 100 days!
  2. PyBites was founded on the 19th of December 2016. We're attending our first PyCon together on May 8th, 2018. Can you calculate how many days from PyBites' inception to our first PyCon meet up?

My code :

from datetime import date, timedelta

start_100days = date(2017, 3, 30)
pybites_founded = date(2016, 12, 19)
pycon_date = date(2018, 5, 8)

def get_hundred_days_end_date():
"""Return a string of yyyy-mm-dd"""
end_date=timedelta(days=100)
finish_day = start_100days + end_date

print(str(finish_day))

def get_days_between_pb_start_first_joint_pycon():
"""Return the int number of days"""
in_between_days = pycon_date - pybites_founded
print(str(in_between_days))

get_hundred_days_end_date()
get_days_between_pb_start_first_joint_pycon()

error return :

============================= test session starts ==============================
platform linux -- Python 3.8.13, pytest-5.4.2, py-1.8.1, pluggy-0.13.1
rootdir: /tmp
plugins: asyncio-0.12.0
2017-07-08
505 days, 0:00:00
collected 2 items

../../tmp/test_calc_dts.py 2017-07-08
F505 days, 0:00:00
F

=================================== FAILURES ===================================
________________________ test_get_hundred_days_end_date ________________________

def test_get_hundred_days_end_date():
  assert get_hundred_days_end_date() == '2017-07-08'

E AssertionError: assert None == '2017-07-08'
E + where None = get_hundred_days_end_date()

/tmp/test_calc_dts.py:6: AssertionError
_______________________ test_get_days_till_pycon_meetup ________________________

def test_get_days_till_pycon_meetup():
  assert get_days_between_pb_start_first_joint_pycon() == 505

E assert None == 505
E + where None = get_days_between_pb_start_first_joint_pycon()

/tmp/test_calc_dts.py:10: AssertionError
=========================== short test summary info ============================
FAILED ../../tmp/test_calc_dts.py::test_get_hundred_days_end_date - Assertion...
FAILED ../../tmp/test_calc_dts.py::test_get_days_till_pycon_meetup - assert N...
============================== 2 failed in 0.07s ===============================

@zzwu29
Copy link

zzwu29 commented Jun 8, 2022 via email

@bbelderbos
Copy link
Collaborator

Hey @OneThirtySeven I quickly checked and this is not an exercise bug, it's a failing submission.

where None = get_hundred_days_end_date() means you are not returning anything from the function.

Change your prints to returns and that fixes that issue.

There is another problem to fix (you're close!), it has to do with the return type of get_days_between_pb_start_first_joint_pycon() - you have str, but as per the test it needs to be int(hint: you can calldayson atimedelta` object ...)

HTH
Bob

@bbelderbos bbelderbos self-assigned this Jun 8, 2022
@II-Tom-Cat-II
Copy link
Author

II-Tom-Cat-II commented Jun 8, 2022

from datetime import date, timedelta

start_100days = date(2017, 3, 30)
pybites_founded = date(2016, 12, 19)
pycon_date = date(2018, 5, 8)

def get_hundred_days_end_date():
"""Return a string of yyyy-mm-dd"""
end_date=timedelta(days=100)
finish_day = str(start_100days + end_date)

return finish_day

def get_days_between_pb_start_first_joint_pycon():
"""Return the int number of days"""
t1 = (pycon_date - pybites_founded).days

return t1

fin_day = get_hundred_days_end_date()
between_day = get_days_between_pb_start_first_joint_pycon()

print("The finish date is ", fin_day)
print("The days in between the founded day and pycon day is",between_day, "days")

##Passed!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants