def valid_cond1(self):
# err_df = rows of self.df not meeting cond1
bad_lines = []
for ix, val in err_df.iterrows():
bad_lines.append("Error in line %s: %s. Cond1 not met.." % (ix,val))
return bad_lines
答案 0 :(得分:0)
您正在while循环的每一步重新初始化两个列表goodList
和badList
。
为避免这种情况,请在while循环之前(之前)初始化它们:
goodList = ["Max","James"]
badList = ["Bradley"]
while True:
childName = input("What name is it?")
childBehaviour = input("Have they been bad or good?")
answer = (childName)
if childBehaviour == 'good':
goodList.append(answer)
print('GoodList' + str(goodList))
if childBehaviour == 'bad':
badList.append(answer)
print('BadList' + str(badList))