0

Halloween challenge

This is my solution to the Halloween candy challenge in Python. It fails the last three tests and I can't figure out what's wrong. Please help. https://code.sololearn.com/c1gvPC6THDh6/?ref=app https://www.sololearn.com/coach/4?ref=app

17th Feb 2020, 12:41 PM
Pavel
Pavel - avatar
2 Answers
+ 1
In this problem, you need to ROUND UP the answer to nearest integer. Round function sometimes rounds up. other times, it rounds down. In those last 3 cases, it is rounding down. Import math and use math.ceil() in place of round() in your code. Cheers
17th Feb 2020, 1:00 PM
Salman Nazeer
Salman Nazeer - avatar
+ 1
I solved it by using math.ceil() to round up - round() was rounding to the closest integer, but the challenge says to round up.
17th Feb 2020, 12:54 PM
Pavel
Pavel - avatar