+ 5
How do I get good at solving Code Coaches?
I always search for solutions but rarely get them right by myself.
33 Antworten
+ 9
And yeah one problem.
When you are comparing two values you must use this == not =.
+ 12
You may want to redo tutorials and ask specific questions here about what you don't understand.
+ 7
ALEXCODES u are literally on the point of solving it, just one problem. INDENTATION,
CORRECT:
if:
else:
WRONG
if:
else:
+ 7
Please remove irrelevant tags. If you feel down, talk to a friend or counsellor.
+ 6
One more detail: the program should print out "give away" instead of "give way".
Find one more discrepancy yourself ;)
+ 5
shouldn't it be popsicles%siblings?
+ 4
My code is up there
+ 4
You dont need elif coz there are only two conditions so if else is ok.
+ 3
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
+ 3
Thanks
+ 3
Still gives error
+ 2
Post a challenge with your solution here so that we may help.
+ 2
siblings = int(input())
popsicles = int(input())
ty = siblings % popsicles
if ty = 0 :
print("give way")
elif ty != 0 :
print("eat them myself")
+ 2
File/usercode/python0
+ 2
siblings = int(input())
popsicles = int(input())
ty = siblings % popsicles
if ty == 0 :
print("give way")
elif ty != 0 :
print("eat them myself")
+ 2
Change the indentation of ur elif.
And "==" is for comparison no "="
+ 2
Neither did i. 👍
+ 2
I have solved two from the easy level Handcrafts and popsicles challenges you can check my code it's here
https://code.sololearn.com/crBj1SmPjAXz/?ref=app
And this is second one
https://code.sololearn.com/c6DyPul28GNv/?ref=app
Up vote if you like it
+ 2
YOUR CODE MUST GIVE CORRECT OUTPUT FOR ALL INPUTS.SO YOU SHOULD KEEP TRYING IT.YOU CAN ALSO TRY SOME PROGRAMMING PROBLEMS IN HACKERRANK IF YOU ARE SERIOUS IN CODING.IT WILL MAKE YOU MORE FAMILIER WITH CODE COACH PROBLEMS.
+ 2
for example if you have 9 popsicles and you want it to divide among 3 people, you will do 9/3 ryt ? and here we are deciding the result by seeing the remaining popsicles.. so the logic should be popsicles % siblings.. try that