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

Multiply view

What's the problem with my answer???

flask_app.py
from flask import Flask

app = Flask(__name__)

@app.route("/multiply/<int:num1>/<int:num2>")
def multiply(num1=5, num2=5):
    return "{} + {} = {}".format(num1, num2, num1 * num2)

2 Answers

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello Paul.

I am not sure which task of the challenge you are stuck at but...

The first thing I noticed is that you did not add a route, you only edited the one route you have declared.

It should look something like this:

@app.route("/multiply")
@app.route("/multiply/<int:num1>/<int:num2>")
def multiply():
    ....

From here you can also move on and adjust that last line (the return line). I think what you provided is overcomplicated, in the end we only need to return a product of 2 ints in the form of a string.

Let me know if still stuck ;)

Vitto

It's still refusing. May you please give me your solution? I'm supposed to return the result of 5 * 5

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Probably something like

return str(5*5)

could work.

This is because we need to return a string.

Hara Gopal K
Hara Gopal K
Courses Plus Student 10,027 Points

hey Vittorio,

why do we need 2 routes here for the first challenge ? what's the use of the first one ?

Thank you Hara

I don't know if it would be something so simple, but you have a plus/addition symbol in the string, rather than the asterisk typically used as the multiplication operator: *