0

Is there a shorter way to write this codes?

fruit = int(input()) #your code goes here # Take the total number of fruits and divide by two to find the total amount of apples. Then check if the apples can be divided by 3. # If it is divisible, print out the quotient. else print out the nearest divisible number. apples = fruit/2 if apples % 3 == 0: print(int(apples/3)) else: remainder = apples % 3 output = (apples - remainder)/3 print(int(output))

10th Nov 2022, 11:32 AM
Toymak3r
3 Answers
+ 2
# for myself: print((int(input())//2)//3)
10th Nov 2022, 3:22 PM
Ervis Meta
Ervis Meta - avatar
0
U can use ternary operator in print
10th Nov 2022, 11:53 AM
Danila Khaminets
Danila Khaminets - avatar
0
Thank you, it works perfectly
10th Nov 2022, 3:52 PM
Toymak3r