Вы получите лучшее понимание, если назовете свои переменные и функции с описательными именами:
data = [(['Andrew'], ['FullTime'], [38]),
(['Fred'], ['PartTime'], [24]),
(['Chris'], ['FullTime'], [38])]
def filter_records(value, records):
result = []
for i in range(len(records)): # i and j are usual variable names for indices (b is not)
record = records[i]
name, work, hours = record # give names to the parts
if work[0] == value: # work[0] since the values are lists (no need for parenthesis)
result.append(record)
return result # no need for parenthesis
FullTimeList = filter_records("FullTime", data)
PartTimeList = filter_records("PartTime", data)
шаблон:
for i in range(len(records)):
record = records[i]
- это анти-шаблон в Python - это означает, что есть лучший способ написать это:
for record in records:
...