【发布时间】:2018-04-16 19:44:59
【问题描述】:
我有一个客户列表(目前只有三个),每个客户都有一个唯一的代码。我希望能够使用收到的输入来搜索客户;地址、名字或姓氏。如果多个值存储在最后一个例如两个 kims - 都应该归还。我在下面包含了我的代码,但过程完成且没有返回。谁能告诉我我的代码哪里出了问题并指出我正确的方向?为什么它不接受输入、搜索列表并返回一个值?请看我的代码:
all_customers = []
class Customer:
customers = []
def __init__(self, first, last, address):
self.first = first
self.last = last
self.address = address
@staticmethod
def search_members():
print()
user_input = input("What customer are you searching for? ")
print()
for i, customer in enumerate (all_customer):
if user_input in all_customer:
print("Test", customers)
customer_1 = Customer('Kim', 'N', 'London')
customer_2 = Customer('Chris', 'E', 'Japan')
customer_3 = Customer('Gill' 'T' 'London')
【问题讨论】:
-
您有两个列表,而您的客户不在其中。为什么会这样?
-
all_customer或all_customers?请注意,您的列表是空的,这是错误的......