【发布时间】:2015-05-17 21:58:21
【问题描述】:
我在 python 3.4 中有一个如下的 for 循环
def checkCustometers(self):
for customer in self.customers_waiting:
if customer.Source == self.location: #if the customer wants to get on at this floor,
self.customers_inside_elevators.append(customer) #place customer into elevator
self.customers_waiting.remove(customer) #The customer isent waiting anymore
比如说在
customer_waiting[4]
if customer.Source == Self.location
然后循环删除
customer_waiting[4] 和 customer_waiting[5]
然后转到位置 4。然后循环继续并查看
customer_waiting[5] 但它实际上是在查看 customer_waiting[6] 跳过 customer_waiting[5]
我该如何解决这个问题?
【问题讨论】:
标签: python python-3.x