+ 1

i need help to solve (code coach) problem task using python

hello guys i'm now here and I'm looking for help please, i start challenge in code coach, the problem is as follows : You have a box of popsicles and you want to give them all away to a group of brothers and sisters. If you have enough left in the box to give them each an even amount you should go for it! If not, they will fight over them, and you should eat them yourself later. Task Given the number of siblings that you are giving popsicles to, determine if you can give them each an even amount or if you shouldn't mention the popsicles at all. Input Format Two integer values, the first one represents the number of siblings, and the second one represents the number of popsicles that you have left in the box. Output Format A string that says 'give away' if you are giving them away, or 'eat them yourself' if you will be eating them yourself. Sample Input 3 9 Sample Output give away I've tried with him by python. please could someone help me to solve it, next comment I will put the code

18th Aug 2023, 5:14 PM
Oussama Qastal
Oussama Qastal - avatar
4 Antworten
+ 4
def distribute_popsicles(siblings, popsicles): if popsicles % siblings == 0: return 'give away' else: return 'eat them yourself' # Read input siblings, popsicles = map(int, input().split()) # Get the result result = distribute_popsicles(siblings, popsicles) # Print the result print(result)
18th Aug 2023, 5:18 PM
Mustafa Raza
+ 1
and this code works too.... siblings = int(input()) popsicles = int(input()) # your code goes here result = popsicles % siblings if popsicles > 0 and result == 0: print ("give away") else: print ("eat them yourself")
19th Aug 2023, 6:58 AM
Mihaly Nyilas
Mihaly Nyilas - avatar
0
thank you very much for your help and support 🙏🏼
18th Aug 2023, 5:19 PM
Oussama Qastal
Oussama Qastal - avatar
0
Thank you too Mihaly for answer and help 🙏🏼
19th Aug 2023, 7:37 PM
Oussama Qastal
Oussama Qastal - avatar