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?
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):
+ 4
You also need to write popsicles=int(input()) instead of popsicles=20 and siblings=int(input()) instead of siblings=10.
+ 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)
+ 3
Elsa Cavendish ,
you are welcome. and it is good news that you found the issue.
happy coding!
+ 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")
+ 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())
...
+ 1
Write a line in if "(popsicles % siblings == 0 or siblings % popsicles == 0)". Output: give away.
+ 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?
+ 1
Elsa Cavandish ,
can you please just publish your current code that creates the issue?
thanks!
+ 1
Thank u so much this works!!! I've tried solving it so many times thank u!
+ 1
And I get it now what I was doing wrong thanks mentor!
0
Lothar, I hope you saw my message in private messages. I hope you will understand me.
0
siblings = int(10)
popsicles = int(20)
#your code goes here
if (popsicles % siblings == 0):
print("give away")
else:
print("eat them yourself")
0
That's not working either