+ 2
My answer for popsicles
siblings = int(input()) popsicles = int(input()) #your code goes here x = popsicles/siblings def share(siblings,popsicles): if x==2: return "give away" elif x%2==0: return "give away" elif x%3==0: return "give away" elif popsicles%siblings==0: return "give away" else: return "eat them yourself" print(share(siblings,popsicles))
7 ответов
+ 3
Faisal Issaka it worked
x = popsicles/siblings
def share(siblings,popsicles):
if x==2 or x%2==0 or x%3==0 or popsicles%siblings==0:
return "give away"
else:
return "eat them yourself"
print(share(siblings,popsicles))
👆👆👆
+ 2
Try combining the conditional statements it should look much simpler and clean
+ 2
I believe a check that popsicles is a multiple of siblings suffices. That means you can shorten all the way down to
#your code goes here
def share(siblings,popsicles):
return (
"give away"
if popsicles%siblings == 0
else "eat them yourself"
)
print(share(siblings,popsicles))
0
Alright, thanks.
I will try it out.
0
Cool 😎
0
😂
Thanks man.
That's some pro shid you just thought me.
Appreciate 🙏🏿
0
My answer was accepted too!
popsicles = int(input())
siblings = int(input())
if popsicles % siblings == 0:
print("give away")
else:
print("eat them yourself")