'How can i Calculate a Queue length

python I am making a bank simulation table and I want to calculate the queue length how can I call the previous row arrival time or start time or any input(I want the queue length to calculate the current row and then go to previous row and do the same calculations) so the queue length can add up, I know how to calculate it but I hope someone tell me how to call the previous row.

import random 
from dataclasses import dataclass
IAT_list=[]
ST_list=[]
qcount=0
pointer=0
size=int(input('enter the number of customers :'))

for k in range(1,size+1):
    print("Enter the arrival time number for your {} customer:".format(k))
    placeholder=int(input())
    IAT_list.append(placeholder)
print("===================================================")    
for k in range(1,size+1):
    print("Enter the service time number for your {} customer:".format(k))
    placeholdertwo=int(input())
    ST_list.append(placeholdertwo)
print("===================================================")    
print("your IAT LIST IS :",IAT_list)
print("===================================================")    
print("your ST LIST IS :",ST_list)
print("===================================================")    

@ dataclass
class Row:
    IAT:int=0
    St:int=0
    Arrival:int=0
    Service_start:int=0
    Send:int=0
    waiting:int=0
    Qlen:int=0
    spend_time=0


    
simtable=[]
#first customer    
c1=Row()
Iat=(IAT_list[pointer])#Iat=random.choice(IAT_list)
St=(ST_list[pointer])#St=random.choice(ST_list)
c1.IAT=Iat
c1.ST=St
c1.Arrival=Iat
c1.Service_start=Iat
c1.Send=c1.Service_start+St
c1.waiting=0
c1.Qlen=0
c1.spend_time= c1.Send - c1.Arrival
simtable.append(c1)


#all customers    
for i in range(1,size):
    c=Row()
    pointer=pointer+1
    Iat=(IAT_list[pointer]) #IAT=random.choice(IAT_list)
    St=(ST_list[pointer])#ST=random.choice(ST_list)
    c.IAT=Iat
    c.ST=St
    c.Arrival=simtable[i-1].Arrival+Iat
    if c.Arrival>simtable[i-1].Send:
        c.Service_start=c.Arrival
        c.Send=c.Service_start+St
        c.waiting=0
    else:
        c.Service_start=simtable[i-1].Send
        c.waiting=simtable[i-1].Send-c.Arrival
        c.Send=c.Service_start+St
    c.spend_time= c.Send - c.Arrival 
    
    if simtable[i-1].Service_start > simtable[i-1].Arrival:
        qcount=qcount+1
    else:
        qcount=0   
    c.Qlen=qcount
      
      
      
        
    simtable.append(c)
print('Cust \t IAT \t ST \t arrival \t start \t end \t\t waiting \t Spend-Time \t Qlen')
i=0
for x in simtable:
   
    print(i+1,"\t",x.IAT,"\t",x.ST,"\t",x.Arrival,"\t\t",x.Service_start,"\t\t",x.Send,"\t\t",x.waiting,"\t\t",x.spend_time,"\t\t",x.Qlen)
    i+=1


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source