Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Flask Basics Welcome to Flask Multiply View

Chastin Davis
PLUS
Chastin Davis
Courses Plus Student 2,299 Points

I don't understand these instructions.

What am I suppose to do when it says add the same arguments to multiply view .I have tried "multiply(arg1, arg2) ... it does not like that.

flask_app.py
from flask import Flask

app = Flask(__name__)


@app.route('/<int:num1>/<int:num2>')
@app.route('/multiply')
def multiply():
    return '25'

1 Answer

jonlunsford
jonlunsford
15,480 Points

Chastin:

The first challenge asked you to add a route for "/multiply", which you did. The second challenge is asking you to create another route that accepts two values, then add those values as arguments to the view. Remember in flask that the view is just another name for the function. Also it asks to set the default value of those arguments each to 5. So what this might look like is:

@app.route('/multiply/<num1>/<num2>')
@app.route('/multiply')
def multiply(num1=5, num2=5):  # added the arguments to the view here.
...

Also, the first step in the challenge reminds you to return a string. You can multiply the numbers together and convert them to a string such as: return str(5 * 5). Or in this case, you can replace the 5 digits with the parameters passed into the view.