+ 1

# Popsicles issue

#My solution to popsicles using python siblings = int(input()) popsicles = int(input()) #your code goes here math = popsicles / siblings if math % 2 == 0: print('give away') else: print('eat them yourself') The last problem fails and I don't understand why?

26th Jan 2024, 6:36 PM
Michael
6 ответов
+ 6
Mike , your *final* code has some duplication. i have taken this code and just only commented out the not required lines. so the code runs properly and has a quite good readability. you can remove all lines that starts with `#`: siblings = int(input()) popsicles = int(input()) #your code goes here #if popsicles > siblings: if popsicles % siblings == 0: print('give away') else: print('eat them yourself') #elif popsicles < siblings: # print('eat them yourself') #else: # print('give away')
30th Jan 2024, 5:57 PM
Lothar
+ 2
we need to know if x%y == 0, not if (x/y)%2 == 0
26th Jan 2024, 7:56 PM
Lisa
+ 1
suppose we have 9 popsicles and 3 siblings. each siblings would get 3 popsicles. we need to know whether the number of popsicles is divisible by the number of siblings. Lothar thanks 😊
26th Jan 2024, 7:10 PM
Lisa
+ 1
Yeah I get that, but that's what I thought I wrote #Divide popsicle between sibs Math = popsicles / siblings #then if the answer of math is even or = 0 they get pops If not, I'm greedy? I don't understand what is wrong as I can't see the final error I feel like its staring me in the face 😂
26th Jan 2024, 7:42 PM
Michael
0
Ohh I hate math 😞😂 thanks both!
26th Jan 2024, 8:05 PM
Michael
0
siblings = int(input()) popsicles = int(input()) #your code goes here if popsicles > siblings: if popsicles % siblings == 0: print('give away') else: print('eat them yourself') elif popsicles < siblings: print('eat them yourself') else: print('give away') SOLVED May not be the most accurate way, but it worked just could not get the last one 🤔 would help if I could see the inputs
29th Jan 2024, 11:50 PM
Michael
Актуальное сегодня
Functions
1 Votes
Python
1 Votes