Dash in 20 Minutes - formatting

In the “Dash in 20 Minutes” tutorial, the following line that is used in the example code does not work:
app.layout = [html.Div(children=‘Hello World’]

This does work:
app.layout = html.Div( [html.Div(children=‘Hello World’) ]

Has Dash changed since that tutorial was created?

Hey @majudd, I actually think, the first line is just a typo.

HI @majudd ,
@AIMPED is right. Your first line of code has a type. You didn’t close the parenthesis.
app.layout = [html.Div(children=‘Hello World’)].

That said, try to install the latest version of Dash. We recently made changes that allowed layouts to be lists.

Ok, I see that I neglected the second parenthesis, thanks for that, but the point still stands.
This line, copied from the “Dash in 20 minutes” tutorial, does not work:
app.layout=[html.Div(children=‘Hello World’)]

But this line does:
app.layout = html.Div([html.Div(children=‘Hello World’)])

Should the tutorial be updated?

That’s a good suggestion, @majudd . I’ll add an update on that in the docs to use the later versions of Dash.

For the second block of code in “Dash in 20 Minutes”,

This layout does not work:
app.layout = [
html.Div(children=‘My First App with Data’),
dash_table.DataTable(data=df.to_dict(‘records’), page_size=10)
]

But this does:
app.layout = html.Div(
[html.Div(children=‘Hello World’),
dash_table.DataTable(data=df.to_dict(‘records’), page_size=10)]
)

Again, should the tutorial be updated?

1 Like