Hi. I tried to answer this but, in Halloween Candy (Python),it is wrong. Can you help me? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi. I tried to answer this but, in Halloween Candy (Python),it is wrong. Can you help me?

houses = int(input()) chance = ((2/houses)*100) round = round(chance) print(round) I am right for the first two results but the wrong ones are locked. Can you tell me what's wrong here?

15th Dec 2022, 12:29 PM
Mcmc
Mcmc - avatar
3 Answers
+ 5
https://code.sololearn.com/cjlF96uKlN1U/?ref=app Use ceil operation instead of round
15th Dec 2022, 5:30 PM
Riya
Riya - avatar
+ 5
have another look at the task description: it ask us to round ***up***
15th Dec 2022, 1:23 PM
Lisa
Lisa - avatar
+ 1
If you don't want to use the imported module you can also round up this way (that's what I did because I'm a newbie and I've not yet come across any lesson on importing anything): houses = int(input()) bills = (2 / houses) * 100 dec = bills - int(bills) if dec > 0: bills += 1 print(int(bills)) When you subtract " (int)Bills" from "bills" you're left with only the decimals, so now all you have to do is add "1" to the solution, if the decimals are more than zero. Hope that helps!
29th Dec 2022, 9:28 PM
Sarah