Skip to content Skip to sidebar Skip to footer

Adding A List Into A Tuple?

These are previously defined. def get_service_code(service): return str(service[0]) service_106_data = filter_routes(bus_stations, '106') #[('106', '1', '1', '43009'), ('106

Solution 1:

I suppose you can use:

return tuple([service_code] + service_data)

Solution 2:

I think you just need

return (service_code, list(set(zip(*service_data)[1])), curr_route)  #("106", [['43009']]) 

its very hard to tell though(but this does give the expected output)

using

make_service([('106', '1', '1', '43009'), ('106', '1', '2', '43179'), ('106', '2', '51', '43009')],"106")

results in ('106', ['1', '2'], ['43009'])

Post a Comment for "Adding A List Into A Tuple?"