With more complex expressions, it can help to lay out the expression on several lines to help readability. There are several tricks of making long lines:
A long string starts and ends with triple quotes (either single or double) -- it can span any number of lines, though Python considers it to be a single string.
A backslash at the end of a line provided the line ends immediately (no trailing blanks!) is one way to extend what would be on a single line to multiple lines. Not recommended and not shown below.
Once an expression has an open bracket, brace, or parenthesis, the rest of the expression can be continued on another line or several other lines (without regard to indentation), because the intent is clear for Python.
1 2 3 4 5 6 7 8 | T = ("one","two",
'''three
four
five''',"six")
R = [2,1]
Z = [ a*b
for a in R
for b in T ]
|