0

Whats wrong with my code

Im just learning python 1week ago so my codes is a mess. All other test cases is right but not the test case #4 Heres the code: siblings = int(input()) popsicles = int(input()) share = (int(popsicles%siblings)) #your code goes here if share%2 == 0 : print ("give away") else: print ("eat them yourself")

8th Sep 2021, 1:41 AM
John Rohb Paloma
John Rohb Paloma - avatar
2 Antworten
+ 2
Don't use share%2 ==0 siblings = int(input()) popsicles = int(input()) share= (int(popsicles%siblings)) if share == 0: print('give away') else: print('eat them yourself')
8th Sep 2021, 2:01 AM
Pariket Thakur
Pariket Thakur - avatar
+ 1
Hi John! Let's say you have 6 siblings and 4 popsicles. So, you can't distribute them among your siblings. But 6%4 = 2; 2%2 = 0. Your code is giving wrong output for these kinds of inputs. Fot that, you can compare variable share with 0 directly. If share == 0:
8th Sep 2021, 1:57 AM
Python Learner
Python Learner - avatar