Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6
Your if statement checks if your division is an even number. Wouldn't it be better to check if there's a remainder from the amount of popsicles?
26th Jun 2022, 12:11 PM
Ausgrindtube
Ausgrindtube - avatar
+ 5
Datboi , don't get confused. you are not far away from solving the task: siblings = int(input()) # enter e.g. 5 popsicles = int(input()) # enter e.g. 15 #a = popsicles / siblings # <<< this is not required if (popsicles % siblings) == 0: # <<< this is the correct use of the modulo division. 15 % 5 => remainder is 0, so we can give away print('give away') elif (siblings > popsicles): print('eat them yourself') else: print('eat them yourself')
26th Jun 2022, 2:25 PM
Lothar
Lothar - avatar
+ 4
% operator gives you reminder. .. What is need for a%2 ? popsiples/siblings why this? According to you..!
26th Jun 2022, 12:32 PM
Jayakrishna 🇮🇳
+ 2
Currently, you are dividing the number of popsicles among children instead of checking if there will be any leftover. Hint: Change the division operator (/). You also need to modify the 'if statement' to follow your result stored in 'a' :)
26th Jun 2022, 12:32 PM
Sandeep
Sandeep - avatar
+ 1
Datboi Great Job :) You can also make this program smaller by just using 'if and else' and removing the 'elif' statements. To make it smaller: > Remove the first 'if' > change the first 'elif' to 'if' > Remove the second 'elif' Final will look like this: if (popsicles % siblings) == 0: # if can be split perfectly, then give away print('give away') else: # if not, eat yourself print('eat them yourself')
26th Jun 2022, 2:41 PM
Sandeep
Sandeep - avatar