Skip to content
Advertisement

How to reduce the number of return statements after if and elifs?

I’m trying to develop a template that adapts itself after user input using Flask. I manage to make it work, but there are too many return statements.

JavaScript

Is there a way to reduce the return statements? I tried this, but it didn’t work:

JavaScript

Advertisement

Answer

Your assignment in render_template is wrong. It will be fixed like below.

JavaScript

You can create a method to reduce code. That takes input and returns title and body.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement