This are previously defined functions
def make_service(service_data, service_code):
routes = []
directions = list(set(map(lambda entry: entry[1], service_data))) #['1', '2']
for direction in directions:
#'1' but if it is '2' then
#[('106', '2', '1', '03239'),...('106', '2', '51', '43009')] will be returned for nxt line
one_direction = filter(lambda entry: entry[1] == direction, service_data)
#if '1' then [('106', '1', '1', '43009')..('106', '1', '48', '03219')]
route = map(lambda thing: thing[3], one_direction) #['43009', '43179',..'03218', '03219']
routes.append(route) #[['43009', '43179',..'03218', '03219']]
return lambda t: service_code if t == 0 else (directions if t == 1 else routes)
# a function is returnrf here !
service_106 = make_service(service_106_data, "106")
service_106_data = filter_routes(smrt_routes, "106")
#[('106', '1', '1', '43009'), ...,('106', '1', '48', '03219'), ('106', '2', '1', '03239'),...('106', '2', '51', '43009')]
So I am suppose to write a function here that returns
[['43009', '43179',..'03218', '43009']]
I have tried:
def get_routes(service):
return map(lambda x: x, service) # I was thinking that
service_106_routes = get_routes(service_106)
print(service_106_routes) # I should get [['43009', '43179',..'03218', '43009']]
How do I get write a function that extracts [['43009', '43179',..'03218', '43009']] from make_service that actually returns a function lambda t? I don't really know how to start writing my code though... Do I start with t?