Dynamic range for y axis

When I put autorange bar graph shows not as good as posible. Then I decided to put fixed range, but my graph sometimes out of y axis.
So I want to put dynamic range [0, df[‘yaxis’][-1] + 500]. It shows error: like it is out of band.

layout = plotly.graph_objs.Layout(
barmode=‘group’,
bargap=0.15,
bargroupgap=0.1,
yaxis={‘range’:([0, cumulative_df[‘max’][-1] + 500])}
)

How to do it dynamically?