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 trialPaul Otieno
6,035 PointsMultiply view
What's the problem with my answer???
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
33,371 PointsHello 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
Iain Simmons
Treehouse Moderator 32,305 PointsI 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: *
Paul Otieno
6,035 PointsPaul Otieno
6,035 PointsIt's still refusing. May you please give me your solution? I'm supposed to return the result of 5 * 5
Vittorio Somaschini
33,371 PointsVittorio Somaschini
33,371 PointsProbably something like
return str(5*5)
could work.
This is because we need to return a string.
Hara Gopal K
Courses Plus Student 10,027 PointsHara Gopal K
Courses Plus Student 10,027 Pointshey Vittorio,
why do we need 2 routes here for the first challenge ? what's the use of the first one ?
Thank you Hara