Making a loop to form a list?

后端 未结 2 833
闹比i
闹比i 2021-01-25 14:27
def make_services(routes_data):
    routes = []
    curr_route = []
    x = split_routes(routes_data)
    service_data1 = x[1]  # (’106’, [(’106’, ’1’, ’1’, ’43009’), ..         


        
2条回答
  •  粉色の甜心
    2021-01-25 14:54

    you return only [(tuple([service_code] + [l] + [[curr_route]]))] which is only one entry, this is why you get only:

    [('106', ['1', '2'], [['43009', ... '43009']])]
    

    you need to store all entries in one list, say, results and append to it each entry in your loop, something like:

    results.append(tuple([service_code] + [l] + [[curr_route]]))
    

    and return:

    return results 
    

提交回复
热议问题