Skip to content
← Back to Community
Hey everyone! It's me again
Profile icon
FARHEENPALAGIRI

Hi everybody, it's me again. I need you to look at something. So the situation was that a school was replacing the desks of 3 classrooms. Each desk holds 2 students. So I wrote this code that, in my opinion, works fine. It looks like this:
one = int(input())
two = int(input())
three = int(input())

total_kids = one + two + three

import math
total_desks = math.ceil(total_kids/2)

print(total_desks)

But when the code inputs a 1, 1 and 1. It's for three different classrooms, and three desks are needed. But I have no clue how to make the program do that. I need help. As usual.

I'm sorry. I know it's two questions in a day, but I am seriously confused on both of them. I'm not exactly Number 1 coder, you know? Help me out please?

Voters
Profile icon
FARHEENPALAGIRI
Comments
hotnewtop
Profile icon
OmniShift

Since you want to calculate for each classroom separately, you should put the input results in a list and loop over it. For each value, use math.ceil as you did and add the result to the total. Its very close to what you already had, just looped and in a slightly different order :)

Profile icon
FARHEENPALAGIRI

@OmniShift Thanks :D