python data structure question | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 4

python data structure question

this is the problem statement You are making a call center application, which should handle customers in a queue. The CallCenter class is implemented as a Queue. Each element of the queue has the topic of the call as its value. The two possible values are 'general' and 'technical'. A 'general' call takes on average 5 minutes to handle, while a 'technical' call requires 10 minutes. The given code adds multiple customers to the Queue from user input. You need to dequeue all added customers, calculate and output the total time required to handle all calls. please help me...the code pass the all test but it didnot pass the last test class CallCenter: def __init__(self): self.customers = [] def is_empty(self): return self.customers == [] def add(self, x): self.customers.insert(0, x) def next(self): return self.customers.pop() c = CallCenter() gcount=0 tcount=0 while True: n = input() if n=='general': gcount+=1 g_time=gcount*5 elif n=='technical': tcount+=1 t_time=tcount*10 elif n == 'end': break c.add(n) c.next() r=g_time+t_time print(r) please tell me whre the mistake i have done

28th May 2021, 1:55 PM
Abhishek Biswas
Abhishek Biswas - avatar
4 Antworten
+ 2
Abhishek Biswas for test is better to save the code on SL Playground and add some print statements to see what happend in different sytuations.
28th May 2021, 2:42 PM
JaScript
JaScript - avatar
+ 1
Hi, this one worked for me: class CallCenter: def __init__(self): self.customers = [] def is_empty(self): return self.customers == [] def add(self, x): self.customers.insert(0, x) def next(self): return self.customers.pop() c = CallCenter() while True: n = input() if n == 'end': break c.add(n) time=0 #your code goes here while not c.is_empty(): a = c.next() if a == "general": time += 5 elif a == "technical": time += 10 print(time)
19th Jan 2022, 10:56 AM
Martin Valdivia
+ 1
while not c.is_empty(): or while c.is_empty()==False:
3rd Mar 2022, 8:34 PM
Liria
Liria - avatar
+ 1
class CallCenter: def __init__(self): self.customers = [] def is_empty(self): return self.customers == [] def add(self, x): self.customers.insert(0, x) def next(self): return self.customers.pop() c = CallCenter() while True: n = input() if n == 'end': break c.add(n) #your code is goes here time=0 while True: if c.is_empty(): break item = c.next() if item=="general": time+=5 elif item=="technical": time+=10 print(time)
2nd Jan 2023, 5:01 AM
MARUBATHULA DEEPTHI
MARUBATHULA DEEPTHI - avatar