My answer for popsicles | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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))

30th May 2022, 9:08 PM
Francis Temanu
Francis Temanu - avatar
7 Answers
+ 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)) 👆👆👆
30th May 2022, 9:19 PM
Francis Temanu
Francis Temanu - avatar
+ 2
Try combining the conditional statements it should look much simpler and clean
30th May 2022, 9:10 PM
Faisal Issaka
Faisal Issaka - avatar
+ 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))
31st May 2022, 5:52 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
0
Alright, thanks. I will try it out.
30th May 2022, 9:14 PM
Francis Temanu
Francis Temanu - avatar
0
Cool 😎
30th May 2022, 9:20 PM
Faisal Issaka
Faisal Issaka - avatar
0
😂 Thanks man. That's some pro shid you just thought me. Appreciate 🙏🏿
30th May 2022, 9:21 PM
Francis Temanu
Francis Temanu - avatar
0
My answer was accepted too! popsicles = int(input()) siblings = int(input()) if popsicles % siblings == 0: print("give away") else: print("eat them yourself")
6th Feb 2023, 1:18 PM
Joshua Nichols
Joshua Nichols - avatar