I am trying to two shorthand If Else statements into a more conventional format, in order to understand it.
For example, from:
if-expression if (condition) else else-expression
to:
if condiction:
if-expression
else:
else-expression
Here are the actual statements I'm trying to breakdown:
Statement 1:
nc = [node_colors[node] if node in node_colors else 'none' for node in projected_routes.nodes()]
Statement 2:
ns = [20 if node in node_colors else 0 for node in projected_routes.nodes()]
Here are my attempts but they do not return the same results as above. I'm not sure what is the role of [] here.
Statement 1:
if node in node_colors:
nc = node_colors[node]
else:
for node in projected_routes.nodes():
'none'
Statement 2:
if node in node_colors:
ns = 20
else:
for node in projected_routes.nodes():
0
Where am I doing wrong? Please someone help me out with this.