0
Fruit bowl : fund the bug
fruit = int(input()) #your code goes here apple = fruit/2 pie = apple/3 a = int(apple) b = apple - a if b == 0: if pie < 1.0: print(0) else: print(int(pie)) else: print("error") Find the error in this code
2 ответов
+ 4
I think you are referring to the code coach practice.
Before you write any code, think more about the solution.
According to the task, you have always whole fruits and you make whole pies. So you need to think (and code) in terms of integer numbers.
You can take advantage of the // operator because it already gives you an integer result, use it instead of / then you do not need to convert the number to int.
And your next line b=apple-a does not make any sense to me.
Ultimately the number of pies is the number of fruit divided by 2 then divided by 3. With basic math this can be simplified to:
pie = fruit // 6
and this is your actual output to be printed, you don't need any additional conditions
0
What is the question?