0

How do I solve all test cases for popsicles problem?https://www.sololearn.com/coach/3?ref=app

I can't solve all test cases I'm a beginner pls help siblings = 10 popsicles = 20 #your code goes here if (popsicles % siblings == 0): print("give away") else: print("eat them yourself") Pls tell me what should I do?

1st Aug 2025, 4:28 PM
Elsa Cavendish
Elsa Cavendish - avatar
14 Risposte
+ 6
Elsa Cavandish , > to follow the 2nd comment from Mila to use input() statements instead of `hard-coded` input values is ok. > the recommendation in the 1st comment to use: `(popsicles % siblings == 0 or siblings % popsicles == 0)` is *not required*, keep your code just as it is: => if (popsicles % siblings == 0):
1st Aug 2025, 7:22 PM
Lothar
Lothar - avatar
+ 4
You also need to write popsicles=int(input()) instead of popsicles=20 and siblings=int(input()) instead of siblings=10.
1st Aug 2025, 5:14 PM
Mila
Mila - avatar
+ 3
Elsa Cavendish , i have done a try with the corrected version, it runs and passes all test cases. siblings = int(input()) popsicles = int(input()) #your code goes here if (popsicles % siblings == 0): print("give away") else: print("eat them yourself") (to avoid typos copy the code and insert it in the python code coach editor. also check that there are no unwanted characters in the code editor)
6th Aug 2025, 7:10 PM
Lothar
Lothar - avatar
+ 3
Elsa Cavendish , you are welcome. and it is good news that you found the issue. happy coding!
7th Aug 2025, 3:27 PM
Lothar
Lothar - avatar
+ 2
siblings = int(input()) popsicles = int(input()) if siblings == 0: print("give away") # or "eat them yourself", depends on problem's edge case handling else: if popsicles % siblings == 0: print("give away") else: print("eat them yourself")
3rd Aug 2025, 7:12 AM
AYESHA NOOR
AYESHA NOOR - avatar
+ 2
Elsa Cavandish , the current code uses 2 hard-coded input values: siblings = int(10) , ... > replace these values with the input() function like: ... siblings = int(input()) ...
5th Aug 2025, 8:33 PM
Lothar
Lothar - avatar
+ 1
Write a line in if "(popsicles % siblings == 0 or siblings % popsicles == 0)". Output: give away.
1st Aug 2025, 5:10 PM
Mila
Mila - avatar
+ 1
Two of the test cases are still wrong in which they need to satisfy "eat them yourself" condition but only one condition can be fulfilled so how do I get all test cases right?
3rd Aug 2025, 11:10 AM
Elsa Cavendish
Elsa Cavendish - avatar
+ 1
Elsa Cavandish , can you please just publish your current code that creates the issue? thanks!
3rd Aug 2025, 2:16 PM
Lothar
Lothar - avatar
+ 1
Thank u so much this works!!! I've tried solving it so many times thank u!
7th Aug 2025, 2:40 PM
Elsa Cavendish
Elsa Cavendish - avatar
+ 1
And I get it now what I was doing wrong thanks mentor!
7th Aug 2025, 2:40 PM
Elsa Cavendish
Elsa Cavendish - avatar
0
Lothar, I hope you saw my message in private messages. I hope you will understand me.
2nd Aug 2025, 7:09 AM
Mila
Mila - avatar
0
siblings = int(10) popsicles = int(20) #your code goes here if (popsicles % siblings == 0): print("give away") else: print("eat them yourself")
5th Aug 2025, 5:14 PM
Elsa Cavendish
Elsa Cavendish - avatar
0
That's not working either
6th Aug 2025, 4:06 PM
Elsa Cavendish
Elsa Cavendish - avatar