+ 4
Why doesn’t my code work?
https://sololearn.com/coach/4/?ref=app (Halloween Candy challenge) Can someone please tell me why my solution is not right? I can’t see the solutions that don’t work. EDIT: Thank you for the answers, I understand now why it wasn’t good. (Though I thought the challenge instructions weren’t clear) Leaving this post up in case others have the same problem.
5 Antworten
+ 6
alepou the reason why your code is not correct is because you are rounding either up or down to the closes int, while the challenge wants you to round up. In other words, if you had 20.10 % chance of getting a dollar, you would have to round it up to 21
+ 6
alepou ,
as already mentioned we have to round the result of the calculation UP. this can be done with the ceil() function. to use it, we have to import the math module.
+ 3
# Hi, alepou !
# You can compare your code with this one:
ch = 2/int(input()) * 100
print(int(ch + 1 if ch > int(ch) else ch))
+ 1
sorry here’s my code: https://code.sololearn.com/cLIYXQ5T27es/?ref=app
0
YuGiMob thank you!