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

Add routes to allow floats or a combination of floats and ints. Where have I gone wrong?

I'm confused..., I've run this in workspaces and I think I have read and compared all the other posts where people are having trouble and still cant get past the 4th task in the challenge. I've run this both with add/ and multiply/ and it works. what is the challenge asking for that I have not provided.

flask_app.py
from flask import Flask

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

3 Answers

Okay.., first, thanks Mohammed. I did go look at that link there that you posted. looks like the moderator says that it works, which it does. I wound up taking a few hours away and just restarted the challenge. After I completed it I was confused because it appeared that I had missed some steps along the way..., and that's where my confusion came from.

I guess I had completed a couple of the tasks ahead and all I needed to do was just click through to the next part of the challenge. It was confusing for me, but after I sat and looked at what I had done and looked at the forums I saw that there were a few others having sorta the same issue one way or another.

I'll have to revisit this exercise again shortly.

ash pulford
ash pulford
4,091 Points

Had the same issue returned a string instead seems to work

from flask import Flask

app = Flask(name) @app.route('/multiply') @app.route('/multiply/<int:num1>/<int:num2>') @app.route('/multiply/<float:num1>/<float:num2>') @app.route('/multiply/<int:num1>/<float:num2>') @app.route('/multiply/<float:num1>/<int:num2>')

def multiply(num1=5, num2=5): return str(num1 * num2)