<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def listlist_and_matrix_to_listdict(graph, weight=None):
 """Transforms the weighted adjacency list representation of a graph of type listlist + optional weight matrix into the listdict representation :param graph: in listlist representation :param weight: optional weight matrix :returns: graph in listdict representation :complexity: linear """

    if weight:
        return [{v:weight[u][v] for v in graph[u]} for u in range(len(graph))]
    else:
        return [{v:None for v in graph[u]} for u in range(len(graph))]